PDFs with PHP part 1 - The Trailer (Page 8 of 10 )
The final lines to be printed are the PDF trailer.
/* Print trailer. */
$this->_out('trailer');
$this->_out('<<');
/* The total number of objects. */
$this->_out('/Size ' . ($this->_n + 1));
/* The root object. */
$this->_out('/Root ' . $this->_n . ' 0 R');
/* The document information object. */
$this->_out('/Info ' . ($this->_n - 1) . ' 0 R');
$this->_out('>>');
$this->_out('startxref');
$this->_out($start_xref); // Where to find the xref.
$this->_out('%%EOF');
$this->_state = 3; // Set the document state to
// closed.
}
Now let's look at the new functions we’ve met in this document closing method. The _newobj() function above is used simply to keep track of objects added to the document.
function _newobj
()
{
/* Increment the object count. */
$this->_n++;
/* Save the byte offset of this object. */
$this->_offsets[$this->_n] = strlen($this->_buffer);
/* Output to buffer. */
$this->_out($this->_n . ' 0 obj');
}
The _putPages() function handles the output of the page content. Here we go through the $_pages array that has been buffering the page content separately, and output it to the main buffer.
Next: Compression >>
More Zend Articles
More By Zend