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

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

http://zoop.googlecode.com/
PHP | 98 lines | 32 code | 10 blank | 56 comment | 4 complexity | fdc82e80465fa7a670c538fd17ed9446 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: FitBoundingBoxVertically.php 20096 2010-01-06 02:05:09Z bkarwin $
21 */
22
23/** Internally used classes */
24require_once 'Zend/Pdf/Element/Array.php';
25require_once 'Zend/Pdf/Element/Name.php';
26require_once 'Zend/Pdf/Element/Numeric.php';
27
28
29/** Zend_Pdf_Destination_Explicit */
30require_once 'Zend/Pdf/Destination/Explicit.php';
31
32/**
33 * Zend_Pdf_Destination_FitBoundingBoxVertically explicit detination
34 *
35 * Destination array: [page /FitBV left]
36 *
37 * (PDF 1.1) Display the page designated by page, with the horizontal coordinate
38 * left positioned at the left edge of the window and the contents of the page
39 * magnified just enough to fit the entire height of its bounding box within the
40 * 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_FitBoundingBoxVertically 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_FitBoundingBoxVertically
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 a page number.');
68        }
69
70        $destinationArray->items[] = new Zend_Pdf_Element_Name('FitBV');
71        $destinationArray->items[] = new Zend_Pdf_Element_Numeric($left);
72
73        return new Zend_Pdf_Destination_FitBoundingBoxVertically($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_FitBoundingBoxVertically
91     */
92    public function setLeftEdge($left)
93    {
94        $this->_destinationArray->items[2] = new Zend_Pdf_Element_Numeric($left);
95        return $this;
96    }
97
98}