File indexing completed on 2024-12-22 05:36:54

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_Pdf
0017  * @subpackage Destination
0018  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0019  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0020  * @version    $Id$
0021  */
0022 
0023 
0024 /** Internally used classes */
0025 // require_once 'Zend/Pdf/Element/Array.php';
0026 // require_once 'Zend/Pdf/Element/Name.php';
0027 // require_once 'Zend/Pdf/Element/Numeric.php';
0028 
0029 
0030 /** Zend_Pdf_Destination_Explicit */
0031 // require_once 'Zend/Pdf/Destination/Explicit.php';
0032 
0033 /**
0034  * Zend_Pdf_Destination_FitBoundingBox explicit detination
0035  *
0036  * Destination array: [page /FitB]
0037  *
0038  * (PDF 1.1) Display the page designated by page, with its contents magnified
0039  * just enough to fit its bounding box entirely within the window both horizontally
0040  * and vertically. If the required horizontal and vertical magnification
0041  * factors are different, use the smaller of the two, centering the bounding box
0042  * within the window in the other dimension.
0043  *
0044  * @package    Zend_Pdf
0045  * @subpackage Destination
0046  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0047  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0048  */
0049 class Zend_Pdf_Destination_FitBoundingBox extends Zend_Pdf_Destination_Explicit
0050 {
0051     /**
0052      * Create destination object
0053      *
0054      * @param Zend_Pdf_Page|integer $page  Page object or page number
0055      * @return Zend_Pdf_Destination_FitBoundingBox
0056      * @throws Zend_Pdf_Exception
0057      */
0058     public static function create($page)
0059     {
0060         $destinationArray = new Zend_Pdf_Element_Array();
0061 
0062         if ($page instanceof Zend_Pdf_Page) {
0063             $destinationArray->items[] = $page->getPageDictionary();
0064         } else if (is_integer($page)) {
0065             $destinationArray->items[] = new Zend_Pdf_Element_Numeric($page);
0066         } else {
0067             // require_once 'Zend/Pdf/Exception.php';
0068             throw new Zend_Pdf_Exception('Page entry must be a Zend_Pdf_Page object or a page number.');
0069         }
0070 
0071         $destinationArray->items[] = new Zend_Pdf_Element_Name('FitB');
0072 
0073         return new Zend_Pdf_Destination_FitBoundingBox($destinationArray);
0074     }
0075 }