You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
3.5 KiB

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