Home >Backend Development >PHP Tutorial >Introduction to several open source projects that use PHP to generate PDF files from HTML, _PHP Tutorial

Introduction to several open source projects that use PHP to generate PDF files from HTML, _PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 10:13:51953browse

Introduction to several open source projects that use PHP to generate PDF files from HTML,

Using PHP coding to generate PDF files is a very time-consuming task. In the early days, developers used PHP and used FPDF to generate PDF files. But nowadays, there are many function libraries available that can generate PDF documents from the HTML files you provide. This makes a previously time-consuming task very simple.

FPDF has been used for a long time and its characteristics are as follows:

FPDF

FPDF is a PHP class that allows generating PDF documents using pure PHP, in other words, without using the PDFlib function library. The F in FPDF stands for free and free: you can use it in any situation and support customization to meet your specific needs

Features:

1. You can select units, page formats and margins
2. Can manage headers and footers
3. Automatic paging
4. Automatic word wrapping and text alignment
5. Support images (JPEG, PNG, gif)
6. Rich colors, support links

By the way, we also introduce some function libraries that can generate PDF directly from HTML.

DomPDF

domPDF converts HTML to PDF. DomPDF follows the HTML layout of CSS2.1, which is a rendering engine written in PHP. DomPDF is style-driven: it downloads and reads external style sheets, inline styles and the style attribute value of HTML elements. And also supports most HTML visible attributes.

Features:

1. Process most CSS2.1 and some CSS3 properties, including @import, @media & @page rules
2. Supports most of the visible attributes of HTML 4.1
3. Support external style sheets, including local or http/ftp links (via fopen-wrappers)
4. Supports complex table structures, including row and column span, separate & collapsed border models and independent cell styles
5. Support images (gif, png, bmp & jpeg)
6. Does not depend on other PDF function libraries

TCPDF

TCPDF can also be used to generate PDF documents, and it is an open source PHP class library.
The TCPDF project started in 2002 and is now used freely by thousands of people. TCPDF is a Free Libre Open Source Software (FLOSS).

Features:

1. Basic functions do not depend on other PDF function libraries
2. Standard page format, supports page format customization, margin customization and unit measurement
3. Support UTF-8 encoding and text direction from right to left languages.
4. Supports TrueTypeUnicode, OpenTypeUnicode, TrueType, OpenType, Type1 and CID-0 fonts
5. Support font subsets and provide methods to publish some XHTML + CSS code, Javascript and Forms
6. Supports conversion of pictures and graphics
7. Support page compression (requires php-zlib extension)
8. Automatically manage headers and footers

For more features, please click: more

From the comment list of the original article, I also searched for related sites and open source projects:

wkhtmltopdf (comments say it is the standard for generating PDF from HTML):
https://code.google.com/p/wkhtmltopdf/
https://github.com/mreiferson/php-wkhtmltox

pdfservices (no need to explain this, just click it and you will know):
http://www.pdfservices.net/

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/912676.htmlTechArticleIntroducing several open source projects that use PHP to generate PDF files from HTML. Using PHP coding to generate PDF files is a very time-consuming process. hours of work. In the early days, developers used PHP and used FPDF to generate PDF files...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn