function _enddoc()
{
$this->_putheader();
$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 = 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;
}