This tutorial is intended for the PHP programmer who needs to incorporate PDF generation in a script without using external libraries such as PDFlib (often unavailable due to licensing restrictions or lack of funds). This tutorial will cover only the basics, which hopefully will give you a good start. PDF has a vast set of features and possibilities which can not be covered in a short tutorial. If you need more than what is covered here, you might want to look at some similar yet more complete solutions available, such as the excellent work done by Olivier Plathey on the FPDF class (http://fpdf.org), on which this tutorial is based. Of course, you may wish to take your own route and for that there is also the PDF reference (be warned: it’s 1,172 pages!) Basic familiarity with using PHP classes is assumed. Knowledge of PDF file structure is not required, as all references are explained.
This method will give us the PDF object with which we can build our document. It sets the initial values for the document, such as page orientation and size, and returns the object.
Also in this method we turn on compression by default. This makes the output PDF files a lot smaller.
The actual setCompression() method is as follows:
function setCompression
($compress) { /* If no gzcompress function is available then default to * false. */ $this->_compress = (function_exists('gzcompress') ? $compress : false); }
However, whilst learning you may wish to explicitly turn off compression, so that you can open your created PDF document with a text editor and see easily what is happening.