/** * Add text to each page after rendering is complete */ protected function _add_page_text() { if ( !count($this->_page_text) ) return; $this->_pdf->suspend_page(""); for ($p = 1; $p <= $this->_page_count; $p++) { $this->_pdf->resume_page("pagenumber=$p"); foreach ($this->_page_text as $pt) { extract($pt); switch ($_t) { case "text": $text = str_replace(array("{PAGE_NUM}","{PAGE_COUNT}"), array($p, $this->_page_count), $text); $this->text($x, $y, $text, $font, $size, $color, $word_space, $char_space, $angle); break; case "script": if (!$eval) { $eval = new PHP_Evaluator($this); } $eval->evaluate($code, array('PAGE_NUM' => $p, 'PAGE_COUNT' => $this->_page_count)); break; } } $this->_pdf->suspend_page(""); } $this->_pdf->resume_page("pagenumber=".$this->_page_number); }
/** * Opens a new 'object' (template in PDFLib-speak) * * While an object is open, all drawing actions are recorded to the * object instead of being drawn on the current page. Objects can * be added later to a specific page or to several pages. * * The return value is an integer ID for the new object. * * @see PDFLib_Adapter::close_object() * @see PDFLib_Adapter::add_object() * * @return int */ function open_object() { $this->_pdf->suspend_page(""); $ret = $this->_pdf->begin_template($this->_width, $this->_height); $this->_pdf->save(); $this->_objs[$ret] = array("start_page" => $this->_page_number); return $ret; }
/** * Close the pdf */ protected function _close() { $this->_place_objects(); // Close all pages $this->_pdf->suspend_page(""); for ($p = 1; $p <= $this->_page_count; $p++) { $this->_pdf->resume_page("pagenumber={$p}"); $this->_pdf->end_page_ext(""); } $this->_pdf->end_document(""); }
/** * Add text to each page after rendering is complete */ protected function _add_page_text() { if (!count($this->_page_text)) { return; } $this->_pdf->suspend_page(""); for ($p = 1; $p <= $this->_page_count; $p++) { $this->_pdf->resume_page("pagenumber={$p}"); foreach ($this->_page_text as $pt) { extract($pt); $text = str_replace(array("{PAGE_NUM}", "{PAGE_COUNT}"), array($p, $this->_page_count), $text); $this->text($x, $y, $text, $font, $size, $color, $adjust, $angle); } $this->_pdf->suspend_page(""); } $this->_pdf->resume_page("pagenumber=" . $this->_page_number); }