If you are looking for creating PDF output of your HTML pages, you can do it using PHP’s PDFlib module. However, there are some libraries for faster development of your script. Some even are not dependent on PDFlib. Please see below for quick overview.
dompdf is an HTML to PDF converter. At its heart, dompdf is (mostly) CSS2.1 compliant HTML layout and rendering engine written in PHP. It is a style-driven renderer: it will download and read external stylesheets, inline style tags, and the style attributes of individual HTML elements. It also supports most presentational HTML attributes.
* handles most CSS2.1 properties, including @import, @media & @page rules
* supports most presentational HTML 4.0 attributes
* supports external stylesheets, either local or through http/ftp (via fopen-wrappers)
* supports complex tables, including row & column spans, separate & collapsed border models, individual cell styling, (no nested tables yet however)
* image support (gif, png & jpeg)
* no dependencies on external PDF libraries, thanks to the R&OS PDF class
* inline PHP support. See below for details.
* PHP 5.0.0+
* Some fonts. PDFs internally support Helvetica, Times-Roman, Courier & Zapf-Dingbats, but if you wish to use other fonts you will need to install some fonts. dompdf supports the same fonts as the underlying R&OS PDF class: Type 1 (.pfb with the corresponding .afm) and TrueType (.ttf). At the minimum, you should probably have the Microsoft core fonts (now available at: http://corefonts.sourceforge.net/). See the INSTALL file for font installation instructions.
Limitations (Known Issues)
* tables can not be nested
* not particularly tolerant to poorly-formed HTML input (using Tidy first may help).
* large files can take a while to render
* ordered lists are currently not supported
FPDF is a PHP class which allows to generate PDF files with pure PHP, that is to say without using the PDFlib library. F from FPDF stands for Free: you may use it for any kind of usage and modify it to suit your needs. The class can produce documents in many languages other than the Western European ones: Central European, Cyrillic, Greek, Baltic and Thai, provided you own TrueType or Type1 fonts with the desired character set
FPDF has other advantages: high level functions. Here is a list of its main features:
* Choice of measure unit, page format and margins
* Page header and footer management
* Automatic page break
* Automatic line break and text justification
* Image support (JPEG, PNG and GIF)
* TrueType, Type1 and encoding support
* Page compression
FPDF requires no extension (except zlib to activate compression and GD for GIF support). It works with PHP 4 and PHP 5 (the latest version requires at least PHP 4.3.10).
TCPDF is an Open Source PHP class for generating PDF documents.
* no external libraries are required for the basic functions;
* supports all ISO page formats;
* supports custom page formats, margins and units of measure;
* supports UTF-8 Unicode and Right-To-Left languages;
* supports TrueTypeUnicode, OpenTypeUnicode, TrueType, OpenType, Type1 and CID-0 fonts;
* supports document encryption;
* includes methods to publish some (x)HTML code;
* includes graphic (geometric) and transformation methods;
* includes a method to print various barcode formats: CODE 39, ANSI MH10.8M-1983, USD-3, 3 of 9, CODE 93, USS-93, Standard 2 of 5, Interleaved 2 of 5, CODE 128 A/B/C, 2 and 5 Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI, POSTNET, PLANET, RMS4CC (Royal Mail 4-state Customer Code), CBC (Customer Bar Code), KIX (Klant index – Customer index), Intelligent Mail Barcode, Onecode, USPS-B-3200, CODABAR, CODE 11, PHARMACODE, PHARMACODE TWO-TRACKS;
* includes methods to set Bookmarks and print a Table of Content;
* includes a method to move pages;
* includes methods for automatic page header and footer management;
* supports automatic page break;
* supports automatic page numbering and page groups;
* supports automatic line break and text justification;
* supports JPEG and PNG images natively, all images supported by GD (GD, GD2, GD2PART, GIF, JPEG, PNG, BMP, XBM, XPM) and all images supported via ImagMagick;
* supports stroke and clipping mode for text;
* supports clipping masks;
* supports Grayscale, RGB, CMYK, Spot Colors and Transparencies;
* supports several annotations, including links, text and file attachments;
* supports page compression (requires zlib extension);
* supports text hyphenation;
* supports transactions to UNDO commands.
HTML 2 PDF
Get a HTML text and generate a PDF file to make it printer-friendly. This PHP script is based upon FPDF PHP script (www.fpdf.org).
HTML To PDF Class
This class can be used to convert an HTML document or Web page using the ABCPDF or EasySW Web services. It can communicate with these services to tell to convert a given URL to PDF. It may also convert a local HTML file by serving it as a remote page passing it as an argument of the current script URL. The converted PDF document may be stored as a local file or served for download.
SQL 2 PDF
This class can be used to generate a PDF document from the results of MySQL database queries. The class can execute one or more given queries and generate dump the results as HTML tables to a temporary page file. The PDF document is generated by calling a remote Web service that fetches the generated HTML page and convert it to the PDF format.