Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
FileAttachment.php
Go to the documentation of this file.
1 <?php
24 #require_once 'Zend/Pdf/Element.php';
25 #require_once 'Zend/Pdf/Element/Array.php';
26 #require_once 'Zend/Pdf/Element/Dictionary.php';
27 #require_once 'Zend/Pdf/Element/Name.php';
28 #require_once 'Zend/Pdf/Element/Numeric.php';
29 #require_once 'Zend/Pdf/Element/String.php';
30 
31 
33 #require_once 'Zend/Pdf/Annotation.php';
34 
45 {
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 
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 }
const TYPE_NAME
Definition: Element.php:35
const TYPE_DICTIONARY
Definition: Element.php:37
__construct(Zend_Pdf_Element $annotationDictionary)
static create($x1, $y1, $x2, $y2, $fileSpecification)