Home >Backend Development >PHP Problem >How to output pdf from php web page

How to output pdf from php web page

(*-*)浩
(*-*)浩Original
2019-09-17 11:01:123955browse

FPDF is a PHP class that allows generating PDF documents using pure PHP, in other words, without using the PDFlib function library.

How to output pdf from php web page

The F in PDF 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. You can manage headers and footers (recommended learning: PHP programming from entry to proficiency)

3. Automatic paging

4. Automatic line wrapping and text alignment

5. Support pictures (JPEG, PNG, gif)

6. Rich colors, support Link

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

DomPDF

domPDF Convert 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 , Support most of the visible attributes of HTML 4.1

3. Support external style sheets, including local or http/ftp links (through fopen-wrappers)

4. Support complex table structures, Including row and column span, separate & collapsed border models and independent cell styles

5. Supports images (gif, png, bmp & jpeg)

6. Does not depend on other PDFs Function library

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. Supports UTF-8 encoding and languages ​​with text direction from right to left.

4. Support TrueTypeUnicode, OpenTypeUnicode, TrueType, OpenType, Type1 and CID-0 and other fonts

5. Support font subsets and provide methods to publish some XHTML CSS code, Javascript and Forms

6. Support the conversion of pictures and graphics

7. Support page compression (requires php-zlib extension)

8. Automatically manage headers and footers

The above is the detailed content of How to output pdf from php web page. For more information, please follow other related articles on the PHP Chinese website!

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