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

/framework/vendor/zend/Zend/Pdf/Destination/FitHorizontally.php

http://zoop.googlecode.com/
PHP | 98 lines | 32 code | 11 blank | 55 comment | 4 complexity | ada82d95708aea35b3e7db0c42bb9cca MD5 | raw file
 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: FitHorizontally.php 20096 2010-01-06 02:05:09Z bkarwin $
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_FitHorizontally explicit detination
35 *
36 * Destination array: [page /FitH top]
37 *
38 * Display the page designated by page, with the vertical coordinate top positioned
39 * at the top edge of the window and the contents of the page magnified
40 * just enough to fit the entire width of the page within the window.
41 *
42 * @package    Zend_Pdf
43 * @subpackage Destination
44 * @copyright  Copyright (c) 2005-2010 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_FitHorizontally 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 $top  Top edge of displayed page
54     * @return Zend_Pdf_Destination_FitHorizontally
55     * @throws Zend_Pdf_Exception
56     */
57    public static function create($page, $top)
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 a page number.');
68        }
69
70        $destinationArray->items[] = new Zend_Pdf_Element_Name('FitH');
71        $destinationArray->items[] = new Zend_Pdf_Element_Numeric($top);
72
73        return new Zend_Pdf_Destination_FitHorizontally($destinationArray);
74    }
75
76    /**
77     * Get top edge of the displayed page
78     *
79     * @return float
80     */
81    public function getTopEdge()
82    {
83        return $this->_destinationArray->items[2]->value;
84    }
85
86    /**
87     * Set top edge of the displayed page
88     *
89     * @param float $top
90     * @return Zend_Pdf_Action_FitHorizontally
91     */
92    public function setTopEdge($top)
93    {
94        $this->_destinationArray->items[2] = new Zend_Pdf_Element_Numeric($top);
95
96        return $this;
97    }
98}