23 #require_once 'Zend/Pdf/Element.php'; 24 #require_once 'Zend/Pdf/Element/Array.php'; 25 #require_once 'Zend/Pdf/Element/String/Binary.php'; 26 #require_once 'Zend/Pdf/Element/Boolean.php'; 27 #require_once 'Zend/Pdf/Element/Dictionary.php'; 28 #require_once 'Zend/Pdf/Element/Name.php'; 29 #require_once 'Zend/Pdf/Element/Null.php'; 30 #require_once 'Zend/Pdf/Element/Numeric.php'; 31 #require_once 'Zend/Pdf/Element/String.php'; 32 #require_once 'Zend/Pdf/Resource/Unified.php'; 34 #require_once 'Zend/Pdf/Canvas/Abstract.php'; 184 public function __construct($param1, $param2 =
null, $param3 =
null)
192 switch ($param1->getType()) {
194 $this->_dictionary = $param1;
195 $this->_objFactory = $param2;
196 $this->_attached =
true;
197 $this->_safeGS =
false;
202 $this->_objFactory = $param2;
203 $pageWidth = $pageHeight = 0;
207 #require_once 'Zend/Pdf/Exception.php'; 212 }
else if ($param1 instanceof
Zend_Pdf_Page && $param2 ===
null && $param3 ===
null) {
216 $this->_objFactory = $param1->_objFactory;
217 $this->_attached = &$param1->_attached;
218 $this->_safeGS =
false;
222 foreach ($param1->_dictionary->getKeys() as $key) {
223 if ($key ==
'Contents') {
230 $this->_dictionary->Contents->items[] = $param1->_dictionary->Contents;
233 foreach ($param1->_dictionary->Contents->items as $srcContentStream) {
234 $this->_dictionary->Contents->items[] = $srcContentStream;
238 $this->_dictionary->$key = $param1->_dictionary->$key;
243 }
else if (is_string($param1) &&
246 if ($param2 !==
null) {
247 $this->_objFactory = $param2;
249 #require_once 'Zend/Pdf/ElementFactory.php'; 252 $this->_attached =
false;
253 $this->_safeGS =
true;
255 switch (strtolower($param1)) {
265 case 'letter-landscape':
272 $pageDim = explode(
':', $param1);
273 if(count($pageDim) == 2 || count($pageDim) == 3) {
274 $pageWidth = $pageDim[0];
275 $pageHeight = $pageDim[1];
281 #require_once 'Zend/Pdf/Exception.php'; 288 }
else if (is_numeric($param1) && is_numeric($param2) &&
290 if ($param3 !==
null) {
291 $this->_objFactory = $param3;
293 #require_once 'Zend/Pdf/ElementFactory.php'; 297 $this->_attached =
false;
298 $this->_safeGS =
true;
299 $pageWidth = $param1;
300 $pageHeight = $param2;
303 #require_once 'Zend/Pdf/Exception.php'; 304 throw new Zend_Pdf_Exception(
'Unrecognized method signature, wrong number of arguments or wrong argument types.');
309 #require_once 'Zend/Pdf.php'; 336 if ($this->_dictionary->Resources->$type ===
null) {
337 $this->_dictionary->Resources->touch();
340 $this->_dictionary->Resources->$type->touch();
345 foreach ($this->_dictionary->Resources->$type->getKeys() as $ResID) {
346 if ($this->_dictionary->Resources->$type->$ResID === $resObject) {
353 $newResName =
$type[0] . $idCounter++;
354 }
while ($this->_dictionary->Resources->$type->$newResName !==
null);
356 $this->_dictionary->Resources->$type->$newResName = $resObject;
357 $this->_objFactory->attach(
$resource->getFactory());
370 if ($this->_dictionary->Resources->ProcSet ===
null) {
371 $this->_dictionary->Resources->touch();
374 $this->_dictionary->Resources->ProcSet->touch();
377 foreach ($this->_dictionary->Resources->ProcSet->items as $procSetEntry) {
378 if ($procSetEntry->value == $procSetName) {
418 $resources = array();
419 $resDictionary = $this->_dictionary->Resources;
421 foreach ($resDictionary->getKeys() as $resType) {
422 $resources[$resType] = array();
424 if ($resType ==
'ProcSet') {
425 foreach ($resDictionary->ProcSet->items as $procSetEntry) {
426 $resources[$resType][] = $procSetEntry->value;
429 $resMap = $resDictionary->$resType;
431 foreach ($resMap->getKeys() as $resId) {
460 return $this->_dictionary->MediaBox->items[3]->value -
461 $this->_dictionary->MediaBox->items[1]->value;
471 return $this->_dictionary->MediaBox->items[2]->value -
472 $this->_dictionary->MediaBox->items[0]->value;
482 $processed = array();
488 foreach ($this->_dictionary->getKeys() as $key) {
489 $dictionary->$key = $this->_dictionary->$key->makeClone(
$factory->getFactory(),
494 $this->_dictionary =
$factory->newObject($dictionary);
496 $this->_attached =
false;
497 $this->_style =
null;
516 foreach ($this->_dictionary->getKeys() as $key) {
517 $dictionary->$key = $this->_dictionary->$key->makeClone(
$factory->getFactory(),
523 $clonedPage->_attached =
false;
548 if ($this->_saveCount != 0) {
549 #require_once 'Zend/Pdf/Exception.php'; 553 if ($this->_contents ==
'') {
562 $this->_dictionary->touch();
564 $currentPageContents = $this->_dictionary->Contents;
566 $this->_dictionary->Contents->items[] = $currentPageContents;
568 $this->_dictionary->Contents->touch();
571 if ((!$this->_safeGS) && (count($this->_dictionary->Contents->items) != 0)) {
580 $newContentsArray->items[] = $this->_objFactory->newStreamObject(
" q\n");
581 foreach ($this->_dictionary->Contents->items as $contentStream) {
582 $newContentsArray->items[] = $contentStream;
584 $newContentsArray->items[] = $this->_objFactory->newStreamObject(
" Q\n");
586 $this->_dictionary->touch();
587 $this->_dictionary->Contents = $newContentsArray;
589 $this->_safeGS =
true;
592 $this->_dictionary->Contents->items[] =
593 $this->_objFactory->newStreamObject($this->_contents);
595 $this->_contents =
'';
610 if ($objFactory === $this->_objFactory) {
615 if ($this->_attached) {
616 #require_once 'Zend/Pdf/Exception.php'; 617 throw new Zend_Pdf_Exception(
'Page is attached to other documen. Use clone $page to get it context free.');
619 $objFactory->
attach($this->_objFactory);
635 return $this->_dictionary->Resources;
648 if ($this->_dictionary->Resources->Font ===
null) {
654 $fontResources = $this->_dictionary->Resources->Font;
656 $fontResourcesUnique = array();
657 foreach ($fontResources->getKeys() as $fontResourceName) {
658 $fontDictionary = $fontResources->$fontResourceName;
662 #require_once 'Zend/Pdf/Exception.php'; 663 throw new Zend_Pdf_Exception(
'Font dictionary has to be an indirect object or object reference.');
666 $fontResourcesUnique[spl_object_hash($fontDictionary->getObject())] = $fontDictionary;
670 #require_once 'Zend/Pdf/Exception.php'; 671 foreach ($fontResourcesUnique as $resourceId => $fontDictionary) {
673 #require_once 'Zend/Pdf/Resource/Font/Extracted.php'; 677 $fonts[$resourceId] = $extractedFont;
679 if ($e->getMessage() !=
'Unsupported font type.') {
698 if ($this->_dictionary->Resources->Font ===
null) {
703 $fontResources = $this->_dictionary->Resources->Font;
705 $fontResourcesUnique = array();
707 #require_once 'Zend/Pdf/Exception.php'; 708 foreach ($fontResources->getKeys() as $fontResourceName) {
709 $fontDictionary = $fontResources->$fontResourceName;
713 #require_once 'Zend/Pdf/Exception.php'; 714 throw new Zend_Pdf_Exception(
'Font dictionary has to be an indirect object or object reference.');
717 $resourceId = spl_object_hash($fontDictionary->getObject());
718 if (isset($fontResourcesUnique[$resourceId])) {
722 $fontResourcesUnique[$resourceId] = 1;
725 if ($fontDictionary->BaseFont->value != $fontName) {
731 #require_once 'Zend/Pdf/Resource/Font/Extracted.php'; 734 if ($e->getMessage() !=
'Unsupported font type.') {
752 $annotationDictionary = $annotation->
getResource();
755 $annotationDictionary = $this->_objFactory->newObject($annotationDictionary);
758 if ($this->_dictionary->Annots ===
null) {
759 $this->_dictionary->touch();
762 $this->_dictionary->Annots->touch();
765 $this->_dictionary->Annots->items[] = $annotationDictionary;
767 $annotationDictionary->touch();
const FILL_METHOD_NON_ZERO_WINDING
static pdfDate($timestamp=null)
const FILL_METHOD_EVEN_ODD
render(Zend_Pdf_ElementFactory_Interface $objFactory)
const SIZE_LETTER_LANDSCAPE
clonePage($factory, &$processed)
_attachResource($type, Zend_Pdf_Resource $resource)
attach(Zend_Pdf_ElementFactory_Interface $factory)
__construct($param1, $param2=null, $param3=null)
_addProcSet($procSetName)
const SHAPE_DRAW_FILL_AND_STROKE
static createFactory($objCount)
attachAnnotation(Zend_Pdf_Annotation $annotation)
const CLONE_MODE_SKIP_PAGES