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_FitBoundingBoxHorizontally explicit detination 0035 * 0036 * Destination array: [page /FitBH top] 0037 * 0038 * (PDF 1.1) Display the page designated by page, with the vertical coordinate 0039 * top positioned at the top edge of the window and the contents of the page 0040 * magnified just enough to fit the entire width of its bounding box within the 0041 * window. 0042 * 0043 * @package Zend_Pdf 0044 * @subpackage Destination 0045 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0046 * @license http://framework.zend.com/license/new-bsd New BSD License 0047 */ 0048 class Zend_Pdf_Destination_FitBoundingBoxHorizontally extends Zend_Pdf_Destination_Explicit 0049 { 0050 /** 0051 * Create destination object 0052 * 0053 * @param Zend_Pdf_Page|integer $page Page object or page number 0054 * @param float $top Top edge of displayed page 0055 * @return Zend_Pdf_Destination_FitBoundingBoxHorizontally 0056 * @throws Zend_Pdf_Exception 0057 */ 0058 public static function create($page, $top) 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('FitBH'); 0072 $destinationArray->items[] = new Zend_Pdf_Element_Numeric($top); 0073 0074 return new Zend_Pdf_Destination_FitBoundingBoxHorizontally($destinationArray); 0075 } 0076 0077 /** 0078 * Get top edge of the displayed page 0079 * 0080 * @return float 0081 */ 0082 public function getTopEdge() 0083 { 0084 return $this->_destinationArray->items[2]->value; 0085 } 0086 0087 /** 0088 * Set top edge of the displayed page 0089 * 0090 * @param float $top 0091 * @return Zend_Pdf_Action_FitBoundingBoxHorizontally 0092 */ 0093 public function setTopEdge($top) 0094 { 0095 $this->_destinationArray->items[2] = new Zend_Pdf_Element_Numeric($top); 0096 return $this; 0097 } 0098 }