/** * Create new Zend_Pdf_Action_GoTo object using specified destination * * @param Zend_Pdf_Destination|string $destination * @return Zend_Pdf_Action_GoTo */ public static function create($destination) { if (is_string($destination)) { require_once 'Zend/Pdf/Destination/Named.php'; $destination = Zend_Pdf_Destination_Named::create($destination); } if (!$destination instanceof Zend_Pdf_Destination) { require_once 'Zend/Pdf/Exception.php'; throw new Zend_Pdf_Exception('$destination parameter must be a Zend_Pdf_Destination object or string.'); } $dictionary = new Zend_Pdf_Element_Dictionary(); $dictionary->Type = new Zend_Pdf_Element_Name('Action'); $dictionary->S = new Zend_Pdf_Element_Name('GoTo'); $dictionary->Next = null; $dictionary->D = $destination->getResource(); return new Zend_Pdf_Action_GoTo($dictionary, new SplObjectStorage()); }
/** * Set link annotation destination * * @param Zend_Pdf_Target|string $target * @return Zend_Pdf_Annotation_Link */ public function setDestination($target) { if (is_string($target)) { #require_once 'Zend/Pdf/Destination/Named.php'; $destination = Zend_Pdf_Destination_Named::create($target); } if (!$target instanceof Zend_Pdf_Target) { #require_once 'Zend/Pdf/Exception.php'; throw new Zend_Pdf_Exception('$target parameter must be a Zend_Pdf_Target object or a string.'); } $this->_annotationDictionary->touch(); $this->_annotationDictionary->Dest = $destination->getResource(); if ($target instanceof Zend_Pdf_Destination) { $this->_annotationDictionary->Dest = $target->getResource(); $this->_annotationDictionary->A = null; } else { $this->_annotationDictionary->Dest = null; $this->_annotationDictionary->A = $target->getResource(); } return $this; }
/** * Set outline target. * Null means no target * * @param Zend_Pdf_Target|string $target * @return Zend_Pdf_Outline * @throws Zend_Pdf_Exception */ public function setTarget($target = null) { $this->_outlineDictionary->touch(); if (is_string($target)) { require_once 'Zend/Pdf/Destination/Named.php'; $target = Zend_Pdf_Destination_Named::create($target); } if ($target === null) { $this->_outlineDictionary->Dest = null; $this->_outlineDictionary->A = null; } else { if ($target instanceof Zend_Pdf_Destination) { $this->_outlineDictionary->Dest = $target->getResource(); $this->_outlineDictionary->A = null; } else { if ($target instanceof Zend_Pdf_Action) { $this->_outlineDictionary->Dest = null; $this->_outlineDictionary->A = $target->getResource(); } else { require_once 'Zend/Pdf/Exception.php'; throw new Zend_Pdf_Exception('Outline target has to be Zend_Pdf_Destination or Zend_Pdf_Action object or string'); } } } return $this; }
<?php /* * To change this template, choose Tools | Templates * and open the template in the editor. */ $pdf = new Zend_Pdf(); $page1 = $pdf->newPage(Zend_Pdf_Page::SIZE_A4); $page2 = $pdf->newPage(Zend_Pdf_Page::SIZE_A4); $page3 = $pdf->newPage(Zend_Pdf_Page::SIZE_A4); // Page created, but not included into pages list $pdf->pages[] = $page1; $pdf->pages[] = $page2; $destination1 = Zend_Pdf_Destination_Fit::create($page2); $destination2 = Zend_Pdf_Destination_Fit::create($page3); // Returns $page2 object $page = $pdf->resolveDestination($destination1); // Returns null, page 3 is not included into document yet $page = $pdf->resolveDestination($destination2); $pdf->setNamedDestination('Page2', $destination1); $pdf->setNamedDestination('Page3', $destination2); // Returns $destination2 $destination = $pdf->getNamedDestination('Page3'); // Returns $destination1 $pdf->resolveDestination(Zend_Pdf_Destination_Named::create('Page2')); // Returns null, page 3 is not included into document yet $pdf->resolveDestination(Zend_Pdf_Destination_Named::create('Page3'));