PageRenderTime 26ms CodeModel.GetById 17ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/framework/vendor/zend/Zend/Pdf/Annotation/FileAttachment.php

http://zoop.googlecode.com/
PHP | 101 lines | 42 code | 13 blank | 46 comment | 5 complexity | 8ea32131797b834f1dab074d3244dc6e 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 Annotation
 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: FileAttachment.php 20096 2010-01-06 02:05:09Z bkarwin $
 21 */
 22
 23/** Internally used classes */
 24require_once 'Zend/Pdf/Element.php';
 25require_once 'Zend/Pdf/Element/Array.php';
 26require_once 'Zend/Pdf/Element/Dictionary.php';
 27require_once 'Zend/Pdf/Element/Name.php';
 28require_once 'Zend/Pdf/Element/Numeric.php';
 29require_once 'Zend/Pdf/Element/String.php';
 30
 31
 32/** Zend_Pdf_Annotation */
 33require_once 'Zend/Pdf/Annotation.php';
 34
 35/**
 36 * A file attachment annotation contains a reference to a file,
 37 * which typically is embedded in the PDF file.
 38 *
 39 * @package    Zend_Pdf
 40 * @subpackage Annotation
 41 * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
 42 * @license    http://framework.zend.com/license/new-bsd     New BSD License
 43 */
 44class Zend_Pdf_Annotation_FileAttachment extends Zend_Pdf_Annotation
 45{
 46    /**
 47     * Annotation object constructor
 48     *
 49     * @throws Zend_Pdf_Exception
 50     */
 51    public function __construct(Zend_Pdf_Element $annotationDictionary)
 52    {
 53        if ($annotationDictionary->getType() != Zend_Pdf_Element::TYPE_DICTIONARY) {
 54            require_once 'Zend/Pdf/Exception.php';
 55            throw new Zend_Pdf_Exception('Annotation dictionary resource has to be a dictionary.');
 56        }
 57
 58        if ($annotationDictionary->Subtype === null  ||
 59            $annotationDictionary->Subtype->getType() != Zend_Pdf_Element::TYPE_NAME  ||
 60            $annotationDictionary->Subtype->value != 'FileAttachment') {
 61            require_once 'Zend/Pdf/Exception.php';
 62            throw new Zend_Pdf_Exception('Subtype => FileAttachment entry is requires');
 63        }
 64
 65        parent::__construct($annotationDictionary);
 66    }
 67
 68    /**
 69     * Create link annotation object
 70     *
 71     * @param float $x1
 72     * @param float $y1
 73     * @param float $x2
 74     * @param float $y2
 75     * @param string $fileSpecification
 76     * @return Zend_Pdf_Annotation_FileAttachment
 77     */
 78    public static function create($x1, $y1, $x2, $y2, $fileSpecification)
 79    {
 80        $annotationDictionary = new Zend_Pdf_Element_Dictionary();
 81
 82        $annotationDictionary->Type    = new Zend_Pdf_Element_Name('Annot');
 83        $annotationDictionary->Subtype = new Zend_Pdf_Element_Name('FileAttachment');
 84
 85        $rectangle = new Zend_Pdf_Element_Array();
 86        $rectangle->items[] = new Zend_Pdf_Element_Numeric($x1);
 87        $rectangle->items[] = new Zend_Pdf_Element_Numeric($y1);
 88        $rectangle->items[] = new Zend_Pdf_Element_Numeric($x2);
 89        $rectangle->items[] = new Zend_Pdf_Element_Numeric($y2);
 90        $annotationDictionary->Rect = $rectangle;
 91
 92        $fsDictionary = new Zend_Pdf_Element_Dictionary();
 93        $fsDictionary->Type = new Zend_Pdf_Element_Name('Filespec');
 94        $fsDictionary->F    = new Zend_Pdf_Element_String($fileSpecification);
 95
 96        $annotationDictionary->FS = $fsDictionary;
 97
 98
 99        return new Zend_Pdf_Annotation_FileAttachment($annotationDictionary);
100    }
101}