PageRenderTime 28ms CodeModel.GetById 25ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 1ms

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

http://zoop.googlecode.com/
PHP | 75 lines | 22 code | 8 blank | 45 comment | 4 complexity | e5dd10b2aadc606400bead954150d7ab 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: FitBoundingBox.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_FitBoundingBox explicit detination
35 *
36 * Destination array: [page /FitB]
37 *
38 * (PDF 1.1) Display the page designated by page, with its contents magnified
39 * just enough to fit its bounding box entirely within the window both horizontally
40 * and vertically. If the required horizontal and vertical magnification
41 * factors are different, use the smaller of the two, centering the bounding box
42 * within the window in the other dimension.
43 *
44 * @package    Zend_Pdf
45 * @subpackage Destination
46 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
47 * @license    http://framework.zend.com/license/new-bsd     New BSD License
48 */
49class Zend_Pdf_Destination_FitBoundingBox extends Zend_Pdf_Destination_Explicit
50{
51    /**
52     * Create destination object
53     *
54     * @param Zend_Pdf_Page|integer $page  Page object or page number
55     * @return Zend_Pdf_Destination_FitBoundingBox
56     * @throws Zend_Pdf_Exception
57     */
58    public static function create($page)
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('FitB');
72
73        return new Zend_Pdf_Destination_FitBoundingBox($destinationArray);
74    }
75}