Introduction of several open source projects using PHP to generate HTML PDF files _php tips

Source: Internet
Author: User
Tags php class wkhtmltopdf

Using PHP encoding to generate PDF files is a time-consuming task. In the early days, developers used PHP and fpdf to generate PDF files. But now, there are a lot of libraries available, and you can generate PDF documents from the HTML files you provide. This makes the previously time-consuming work very simple.

Fpdf is used very early, and its characteristics are as follows:

FPDF

Fpdf is a PHP class that allows PDF documents to be generated using pure PHP, in other words, the Pdflib function library is not used. The F in Fpdf is free and free: You can use it in any case and support customization to meet your specific needs

Characteristics:

1, you can select the cell, page format and margins
2, can manage headers and footers
3. Automatic paging
4, automatic line wrapping and text alignment
5, support picture (jpeg,png,gif)
6, rich color, support links

It also introduces a library of functions that can generate PDFs 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 styled: it downloads and reads the outer-chain style sheet, inline style, and HTML element's style property values. Most HTML-visible properties are also supported.

Characteristics:

1, handling most CSS2.1 and a little CSS3 properties, including @import, @media & @page rules
2, support for most of the visible properties of HTML 4.1
3. Support external style sheets, including local or http/ftp links (via Fopen-wrappers)
4, support complex table structure, including row and column of Span,separate & collapsed border models and independent cell style
5. Support pictures (GIF, PNG, BMP & JPEG)
6, do not rely on the other PDF function library

TCPDF

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

Characteristics:

1, the basic function does not depend on other PDF function library
2, the standard page format, support page format customization, margin customization and unit measurement
3, Support UTF-8 encoding and text direction from right to left language.
4, Support Truetypeunicode, Opentypeunicode, TrueType, OpenType, Type1 and CID-0 fonts
5, support font subset, and provide methods to publish some XHTML + CSS code, Javascript and Forms
6, support the transformation of pictures and graphics
7, Support page compression (need php-zlib expansion)
8. Automatically manage headers and footers

More features please stamp: more

From the comments list in the original text, I also have the relevant sites and open source projects:

Wkhtmltopdf (commented that the standard for HTML-generated PDF):
https://code.google.com/p/wkhtmltopdf/
Https://github.com/mreiferson/php-wkhtmltox

Pdfservices (This does not need to explain, poke to know):
http://www.pdfservices.net/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.