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_FitHorizontally explicit detination 0035 * 0036 * Destination array: [page /FitH top] 0037 * 0038 * Display the page designated by page, with the vertical coordinate top positioned 0039 * at the top edge of the window and the contents of the page magnified 0040 * just enough to fit the entire width of the page within the window. 0041 * 0042 * @package Zend_Pdf 0043 * @subpackage Destination 0044 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0045 * @license http://framework.zend.com/license/new-bsd New BSD License 0046 */ 0047 class Zend_Pdf_Destination_FitHorizontally extends Zend_Pdf_Destination_Explicit 0048 { 0049 /** 0050 * Create destination object 0051 * 0052 * @param Zend_Pdf_Page|integer $page Page object or page number 0053 * @param float $top Top edge of displayed page 0054 * @return Zend_Pdf_Destination_FitHorizontally 0055 * @throws Zend_Pdf_Exception 0056 */ 0057 public static function create($page, $top) 0058 { 0059 $destinationArray = new Zend_Pdf_Element_Array(); 0060 0061 if ($page instanceof Zend_Pdf_Page) { 0062 $destinationArray->items[] = $page->getPageDictionary(); 0063 } else if (is_integer($page)) { 0064 $destinationArray->items[] = new Zend_Pdf_Element_Numeric($page); 0065 } else { 0066 // require_once 'Zend/Pdf/Exception.php'; 0067 throw new Zend_Pdf_Exception('Page entry must be a Zend_Pdf_Page object or a page number.'); 0068 } 0069 0070 $destinationArray->items[] = new Zend_Pdf_Element_Name('FitH'); 0071 $destinationArray->items[] = new Zend_Pdf_Element_Numeric($top); 0072 0073 return new Zend_Pdf_Destination_FitHorizontally($destinationArray); 0074 } 0075 0076 /** 0077 * Get top edge of the displayed page 0078 * 0079 * @return float 0080 */ 0081 public function getTopEdge() 0082 { 0083 return $this->_destinationArray->items[2]->value; 0084 } 0085 0086 /** 0087 * Set top edge of the displayed page 0088 * 0089 * @param float $top 0090 * @return Zend_Pdf_Action_FitHorizontally 0091 */ 0092 public function setTopEdge($top) 0093 { 0094 $this->_destinationArray->items[2] = new Zend_Pdf_Element_Numeric($top); 0095 0096 return $this; 0097 } 0098 }