Beispiel #1
0
 public function testProcessing()
 {
     $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);
     // not actually included into pages array
     $pdf->pages[] = $page1;
     $pdf->pages[] = $page2;
     $this->assertTrue(count($pdf->getNamedDestinations()) == 0);
     // require_once 'Zend/Pdf/Destination/Fit.php';
     $destination1 = Zend_Pdf_Destination_Fit::create($page1);
     $destination2 = Zend_Pdf_Destination_Fit::create($page2);
     $action1 = Zend_Pdf_Action_GoTo::create($destination1);
     $pdf->setNamedDestination('GoToPage1', $action1);
     $this->assertTrue($pdf->getNamedDestination('GoToPage1') === $action1);
     $this->assertTrue($pdf->getNamedDestination('GoToPage9') === null);
     $pdf->setNamedDestination('Page2', $destination2);
     $this->assertTrue($pdf->getNamedDestination('Page2') === $destination2);
     $this->assertTrue($pdf->getNamedDestination('Page9') === null);
     $pdf->setNamedDestination('Page1', $destination1);
     $pdf->setNamedDestination('Page1_1', Zend_Pdf_Destination_Fit::create(1));
     $pdf->setNamedDestination('Page9_1', Zend_Pdf_Destination_Fit::create(9));
     // will be egnored
     $action3 = Zend_Pdf_Action_GoTo::create(Zend_Pdf_Destination_Fit::create($page3));
     $pdf->setNamedDestination('GoToPage3', $action3);
     $this->assertTrue(strpos($pdf->render(), '[(GoToPage1) <</Type /Action /S /GoTo /D [3 0 R /Fit ] >> (Page1) [3 0 R /Fit ] (Page1_1) [1 /Fit ] (Page2) [4 0 R /Fit ] ]') !== false);
 }
Beispiel #2
0
<?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'));
Beispiel #3
0
 public function testCreate()
 {
     $pdf = new Zend_Pdf();
     $page1 = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
     $page2 = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
     $destination = Zend_Pdf_Destination_Zoom::create($page2, 0, 842, 0.5);
     $this->assertTrue($destination instanceof Zend_Pdf_Destination_Zoom);
     $this->assertEquals($destination->getResource()->toString(), '[4 0 R /XYZ 0 842 0.5 ]');
     $destination = Zend_Pdf_Destination_Fit::create($page2);
     $this->assertTrue($destination instanceof Zend_Pdf_Destination_Fit);
     $this->assertEquals($destination->getResource()->toString(), '[4 0 R /Fit ]');
     $destination = Zend_Pdf_Destination_FitHorizontally::create($page2, 842);
     $this->assertTrue($destination instanceof Zend_Pdf_Destination_FitHorizontally);
     $this->assertEquals($destination->getResource()->toString(), '[4 0 R /FitH 842 ]');
     $destination = Zend_Pdf_Destination_FitVertically::create(2, 0);
     $this->assertTrue($destination instanceof Zend_Pdf_Destination_FitVertically);
     $this->assertEquals($destination->getResource()->toString(), '[2 /FitV 0 ]');
     $destination = Zend_Pdf_Destination_FitRectangle::create($page1, 0, 10, 595, 842);
     $this->assertTrue($destination instanceof Zend_Pdf_Destination_FitRectangle);
     $this->assertEquals($destination->getResource()->toString(), '[3 0 R /FitR 0 10 595 842 ]');
     $destination = Zend_Pdf_Destination_FitBoundingBox::create(1);
     $this->assertTrue($destination instanceof Zend_Pdf_Destination_FitBoundingBox);
     $this->assertEquals($destination->getResource()->toString(), '[1 /FitB ]');
     $destination = Zend_Pdf_Destination_FitBoundingBoxHorizontally::create($page2, 842);
     $this->assertTrue($destination instanceof Zend_Pdf_Destination_FitBoundingBoxHorizontally);
     $this->assertEquals($destination->getResource()->toString(), '[4 0 R /FitBH 842 ]');
     $destination = Zend_Pdf_Destination_FitBoundingBoxVertically::create($page2, 0);
     $this->assertTrue($destination instanceof Zend_Pdf_Destination_FitBoundingBoxVertically);
     $this->assertEquals($destination->getResource()->toString(), '[4 0 R /FitBV 0 ]');
 }
Beispiel #4
0
 public function testGetDestination2()
 {
     $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;
     require_once 'Zend/Pdf/Destination/Fit.php';
     $action1 = Zend_Pdf_Action_GoTo::create(Zend_Pdf_Destination_Fit::create($page2));
     $action2 = Zend_Pdf_Action_GoTo::create(Zend_Pdf_Destination_Fit::create($page3));
     $this->assertTrue($pdf->resolveDestination($action1->getDestination()) === $page2);
     $this->assertTrue($pdf->resolveDestination($action2->getDestination()) === null);
 }