PageRenderTime 9ms CodeModel.GetById 3ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/library/Zend/Pdf/Destination/FitVertically.php

https://bitbucket.org/hamidrezas/melobit
PHP | 98 lines | 32 code | 11 blank | 55 comment | 4 complexity | 2a67af43da2086d6db68690eaae25a22 MD5 | raw file
Possible License(s): AGPL-1.0
 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-2012 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license    http://framework.zend.com/license/new-bsd     New BSD License
20 * @version    $Id: FitVertically.php 24594 2012-01-05 21:27:01Z matthew $
21 */
22
23
24/** Internally used classes */
25require_once 'Zend/Pdf/Element/Array.php';
26require_once 'Zend/Pdf/Element/Name.php';
27require_once 'Zend/Pdf/Element/Numeric.php';
28
29
30/** Zend_Pdf_Destination_Explicit */
31require_once 'Zend/Pdf/Destination/Explicit.php';
32
33/**
34 * Zend_Pdf_Destination_FitVertically explicit detination
35 *
36 * Destination array: [page /FitV left]
37 *
38 * Display the page designated by page, with the horizontal coordinate left positioned
39 * at the left edge of the window and the contents of the page magnified
40 * just enough to fit the entire height of the page within the window.
41 *
42 * @package    Zend_Pdf
43 * @subpackage Destination
44 * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
45 * @license    http://framework.zend.com/license/new-bsd     New BSD License
46 */
47class Zend_Pdf_Destination_FitVertically extends Zend_Pdf_Destination_Explicit
48{
49    /**
50     * Create destination object
51     *
52     * @param Zend_Pdf_Page|integer $page  Page object or page number
53     * @param float $left  Left edge of displayed page
54     * @return Zend_Pdf_Destination_FitVertically
55     * @throws Zend_Pdf_Exception
56     */
57    public static function create($page, $left)
58    {
59        $destinationArray = new Zend_Pdf_Element_Array();
60
61        if ($page instanceof Zend_Pdf_Page) {
62            $destinationArray->items[] = $page->getPageDictionary();
63        } else if (is_integer($page)) {
64            $destinationArray->items[] = new Zend_Pdf_Element_Numeric($page);
65        } else {
66            require_once 'Zend/Pdf/Exception.php';
67            throw new Zend_Pdf_Exception('Page entry must be a Zend_Pdf_Page object or page number.');
68        }
69
70        $destinationArray->items[] = new Zend_Pdf_Element_Name('FitV');
71        $destinationArray->items[] = new Zend_Pdf_Element_Numeric($left);
72
73        return new Zend_Pdf_Destination_FitVertically($destinationArray);
74    }
75
76    /**
77     * Get left edge of the displayed page
78     *
79     * @return float
80     */
81    public function getLeftEdge()
82    {
83        return $this->_destinationArray->items[2]->value;
84    }
85
86    /**
87     * Set left edge of the displayed page
88     *
89     * @param float $left
90     * @return Zend_Pdf_Action_FitVertically
91     */
92    public function setLeftEdge($left)
93    {
94        $this->_destinationArray->items[2] = new Zend_Pdf_Element_Numeric($left);
95
96        return $this;
97    }
98}