protected function _endDoc()
{
$this->_putPages();
$this->_putResources();
// Info
$this->_newobj();
$this->_out('<<');
$this->_putInfo();
$this->_out('>>');
$this->_out('endobj');
// Catalog
$this->_newobj();
$this->_out('<<');
$this->_putCatalog();
$this->_out('>>');
$this->_out('endobj');
// Cross-ref
$o = $this->_buflen + strlen($this->_buffer);
$this->_out('xref');
$this->_out('0 ' . ($this->_n + 1));
$this->_out('0000000000 65535 f ');
for ($i = 1; $i <= $this->_n; $i++) {
$this->_out(sprintf('%010d 00000 n ', $this->_offsets[$i]));
}
// Trailer
$this->_out('trailer');
$this->_out('<<');
$this->_putTrailer();
$this->_out('>>');
$this->_out('startxref');
$this->_out($o);
$this->_out('%%EOF');
$this->_state = 3;
}