Tuesday, October 5, 2010

Create PDF documents Online with TCPDF

Posted by OlafMay 27, 2010

Many web applications using PDF documents for invoices, contracts and many other doc types. There are a few PHP classes which are able to create PDF documents online, one of them is TCPDF. This tutorial is about how-to use the TCPDF class while creating a simple invoice document. If you like to take a sneak peak on the result, check this website which generates the PDF Invoice document on the fly.

Why TCPDF and not some other PHP class?

TCPDF is based on the FPDF class, a very stable project written for PHP4. Since several years has TCPDF much more features than FPDF and is written for PHP5 (there is also a PHP4 version). The TCPDF has also some great documentation and of course examples for all important PDF jobs like:
WriteHTML and RTL support, Multiple columns, JavaScript and Forms, Bookmarks (Table of Content), Multicell complex alignment, Barcodes, Set PDF viewer display preferences, EPS/AI vectorial images and many more.

The Zend Framework has some PDF class too…

Yes right, the first plan was to write this tutorial about the Zend Framework, but after writing a few rows of code I’ve noticed that the PDF Class is missing some important functions, like the MultiCell, which is used to wrap multiple rows of text. It’s a required function which was suggested as the Zend_Pdf_Cell 2 years ago and didn’t find the way to the core version until now. I like the Zend Framework a lot but not for creating PDF documents, the PDF class is much too limited.

No comments:

Post a Comment