To add the PDF document generation function to the PHP project, the open-source class library TCPDF is undoubtedly the best choice. I personally feel that its biggest advantage is that it can directly use HTML-style strings to generate PDF, that is, it can determine the style and content of the document through HTML, and then export the PDF file with TCPDF. The official website of TCPDF is as follows: www.tcpdf.org download
To add the PDF document generation function to the PHP project, the open-source class library TCPDF is undoubtedly the best choice. I personally feel that its biggest advantage is that it can directly use HTML-style strings to generate PDF, that is, it can determine the style and content of the document through HTML, and then export the PDF file with TCPDF. TCPDF official website is as follows: Download The http://www.tcpdf.org
To add the PDF document generation function to the PHP project, the open-source class library TCPDF is undoubtedly the best choice. I personally think its biggest advantage is that it can directly use HTML strings to generate PDF, that is, it can determine the document format and content through HTML, and then export the PDF file with TCPDF.
The official website of TCPDF is as follows:
Http://www.tcpdf.org
The downloaded TCPDF directory structure is as follows:
Where:
Cache directory:Some string files in different formats used to generate PDF files (for example in examples)
Config directory:The configuration file directory of TCPDF, which defines the constants used by TCPDF.
Doc directory:Access the doc path in the browser will jump to the official website of TCPDF
Examples directory:TCPDF example, including 65 demos for different operations
Fonts directory:Store font files
Images directory:Store image files
Tcpdf. php file:TCPDF main class. All Main functions are in this file.
After reading 65 examples provided by TCPDF, you can fully master its usage. You can perform the following five steps:
1. require_once import the tcpdf. php file and the corresponding language of the config/lang/directory
2. instantiate TCPDF
3. Set the format of a PDF document, including the document information, header, footer, Font, outer spacing, image border, and paging.
4. The content of the imported PDF document can be a single line or multiple lines of simple strings, or HTML strings.
5. output PDF document
TCPDF open-source projects are very active. Basically, new versions of TCPDF packages will be released every few days. Therefore, new bugs are generally handled in a short time. I have discovered a bug in HTML color parsing. after submitting the bug, I solved it in the new version released the next day.
In addition, the following link explains how to create a Chinese font that is not found in the fonts directory:
Http://www.yinzhili.com/2009/08/using-tcpdf-to-generate-pdf-in-chinese.html