protected function _putPages() { $nb = $this->_page; if (!empty($this->_alias_nb_pages)) { // Replace number of pages. for ($n = 1; $n <= $nb; $n++) { $this->_pages[$n] = str_replace($this->_alias_nb_pages, $nb, $this->_pages[$n]); } } if ($this->_default_orientation == 'P') { $wPt = $this->fwPt; $hPt = $this->fhPt; } else { $wPt = $this->fhPt; $hPt = $this->fwPt; } $filter = $this->_compress ? '/Filter /FlateDecode ' : ''; for ($n = 1; $n <= $nb; $n++) { // Page $this->_newobj(); $this->_out('<</Type /Page'); $this->_out('/Parent 1 0 R'); if (isset($this->_orientation_changes[$n])) { $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]', $hPt, $wPt)); } $this->_out('/Resources 2 0 R'); if (isset($this->_page_links[$n])) { // Links $annots = '/Annots ['; foreach ($this->_page_links[$n] as $pl) { $rect = sprintf('%.2F %.2F %.2F %.2F', $pl[0], $pl[1], $pl[0] + $pl[2], $pl[1] - $pl[3]); $annots .= '<</Type /Annot /Subtype /Link /Rect [' . $rect . '] /Border [0 0 0] '; if (is_string($pl[4])) { $annots .= '/A <</S /URI /URI ' . $this->_textString($pl[4]) . '>>>>'; } else { $l = $this->_links[$pl[4]]; $height = isset($this->_orientation_changes[$l[0]]) ? $wPt : $hPt; $annots .= sprintf('/Dest [%d 0 R /XYZ 0 %.2F null]>>', 1 + 2 * $l[0], $height - $l[1] * $this->_scale); } } $this->_out($annots . ']'); } $this->_out('/Contents ' . ($this->_n + 1) . ' 0 R>>'); $this->_out('endobj'); // Page content $p = $this->_compress ? gzcompress($this->_pages[$n]) : $this->_pages[$n]; $this->_newobj(); $this->_out('<<' . $filter . '/Length ' . strlen($p) . '>>'); $this->_putStream($p); $this->_out('endobj'); } // Pages root $this->_offsets[1] = $this->_buflen + strlen($this->_buffer); $this->_out('1 0 obj'); $this->_out('<</Type /Pages'); $kids = '/Kids ['; for ($i = 0; $i < $nb; $i++) { $kids .= 3 + 2 * $i . ' 0 R '; } $this->_out($kids . ']'); $this->_out('/Count ' . $nb); $this->_out(sprintf('/MediaBox [0 0 %.2F %.2F]', $wPt, $hPt)); $this->_out('>>'); $this->_out('endobj'); }