web/lib/Zend/Pdf/Destination/FitBoundingBoxHorizontally.php
changeset 64 162c1de6545a
parent 19 1c2f13fd785c
child 68 ecaf28ffe26e
equal deleted inserted replaced
63:5b37998e522e 64:162c1de6545a
       
     1 <?php
       
     2 /**
       
     3  * Zend Framework
       
     4  *
       
     5  * LICENSE
       
     6  *
       
     7  * This source file is subject to the new BSD license that is bundled
       
     8  * with this package in the file LICENSE.txt.
       
     9  * It is also available through the world-wide-web at this URL:
       
    10  * http://framework.zend.com/license/new-bsd
       
    11  * If you did not receive a copy of the license and are unable to
       
    12  * obtain it through the world-wide-web, please send an email
       
    13  * to license@zend.com so we can send you a copy immediately.
       
    14  *
       
    15  * @category   Zend
       
    16  * @package    Zend_Pdf
       
    17  * @subpackage Destination
       
    18  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    20  * @version    $Id: FitBoundingBoxHorizontally.php 20096 2010-01-06 02:05:09Z bkarwin $
       
    21  */
       
    22 
       
    23 
       
    24 /** Internally used classes */
       
    25 require_once 'Zend/Pdf/Element/Array.php';
       
    26 require_once 'Zend/Pdf/Element/Name.php';
       
    27 require_once 'Zend/Pdf/Element/Numeric.php';
       
    28 
       
    29 
       
    30 /** Zend_Pdf_Destination_Explicit */
       
    31 require_once 'Zend/Pdf/Destination/Explicit.php';
       
    32 
       
    33 /**
       
    34  * Zend_Pdf_Destination_FitBoundingBoxHorizontally explicit detination
       
    35  *
       
    36  * Destination array: [page /FitBH top]
       
    37  *
       
    38  * (PDF 1.1) Display the page designated by page, with the vertical coordinate
       
    39  * top positioned at the top edge of the window and the contents of the page
       
    40  * magnified just enough to fit the entire width of its bounding box within the
       
    41  * window.
       
    42  *
       
    43  * @package    Zend_Pdf
       
    44  * @subpackage Destination
       
    45  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    46  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    47  */
       
    48 class Zend_Pdf_Destination_FitBoundingBoxHorizontally extends Zend_Pdf_Destination_Explicit
       
    49 {
       
    50     /**
       
    51      * Create destination object
       
    52      *
       
    53      * @param Zend_Pdf_Page|integer $page  Page object or page number
       
    54      * @param float $top   Top edge of displayed page
       
    55      * @return Zend_Pdf_Destination_FitBoundingBoxHorizontally
       
    56      * @throws Zend_Pdf_Exception
       
    57      */
       
    58     public static function create($page, $top)
       
    59     {
       
    60         $destinationArray = new Zend_Pdf_Element_Array();
       
    61 
       
    62         if ($page instanceof Zend_Pdf_Page) {
       
    63             $destinationArray->items[] = $page->getPageDictionary();
       
    64         } else if (is_integer($page)) {
       
    65             $destinationArray->items[] = new Zend_Pdf_Element_Numeric($page);
       
    66         } else {
       
    67             require_once 'Zend/Pdf/Exception.php';
       
    68             throw new Zend_Pdf_Exception('Page entry must be a Zend_Pdf_Page object or a page number.');
       
    69         }
       
    70 
       
    71         $destinationArray->items[] = new Zend_Pdf_Element_Name('FitBH');
       
    72         $destinationArray->items[] = new Zend_Pdf_Element_Numeric($top);
       
    73 
       
    74         return new Zend_Pdf_Destination_FitBoundingBoxHorizontally($destinationArray);
       
    75     }
       
    76 
       
    77     /**
       
    78      * Get top edge of the displayed page
       
    79      *
       
    80      * @return float
       
    81      */
       
    82     public function getTopEdge()
       
    83     {
       
    84         return $this->_destinationArray->items[2]->value;
       
    85     }
       
    86 
       
    87     /**
       
    88      * Set top edge of the displayed page
       
    89      *
       
    90      * @param float $top
       
    91      * @return Zend_Pdf_Action_FitBoundingBoxHorizontally
       
    92      */
       
    93     public function setTopEdge($top)
       
    94     {
       
    95         $this->_destinationArray->items[2] = new Zend_Pdf_Element_Numeric($top);
       
    96         return $this;
       
    97     }
       
    98 }