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.

95 lines
3.3 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 text annotation represents a "sticky note" attached to a point in the PDF document.
  33. *
  34. * @package Zend_Pdf
  35. * @subpackage Annotation
  36. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  37. * @license http://framework.zend.com/license/new-bsd New BSD License
  38. */
  39. class Zend_Pdf_Annotation_Text extends Zend_Pdf_Annotation
  40. {
  41. /**
  42. * Annotation object constructor
  43. *
  44. * @throws Zend_Pdf_Exception
  45. */
  46. public function __construct(Zend_Pdf_Element $annotationDictionary)
  47. {
  48. if ($annotationDictionary->getType() != Zend_Pdf_Element::TYPE_DICTIONARY) {
  49. // require_once 'Zend/Pdf/Exception.php';
  50. throw new Zend_Pdf_Exception('Annotation dictionary resource has to be a dictionary.');
  51. }
  52. if ($annotationDictionary->Subtype === null ||
  53. $annotationDictionary->Subtype->getType() != Zend_Pdf_Element::TYPE_NAME ||
  54. $annotationDictionary->Subtype->value != 'Text') {
  55. // require_once 'Zend/Pdf/Exception.php';
  56. throw new Zend_Pdf_Exception('Subtype => Text entry is requires');
  57. }
  58. parent::__construct($annotationDictionary);
  59. }
  60. /**
  61. * Create link annotation object
  62. *
  63. * @param float $x1
  64. * @param float $y1
  65. * @param float $x2
  66. * @param float $y2
  67. * @param string $text
  68. * @return Zend_Pdf_Annotation_Text
  69. */
  70. public static function create($x1, $y1, $x2, $y2, $text)
  71. {
  72. $annotationDictionary = new Zend_Pdf_Element_Dictionary();
  73. $annotationDictionary->Type = new Zend_Pdf_Element_Name('Annot');
  74. $annotationDictionary->Subtype = new Zend_Pdf_Element_Name('Text');
  75. $rectangle = new Zend_Pdf_Element_Array();
  76. $rectangle->items[] = new Zend_Pdf_Element_Numeric($x1);
  77. $rectangle->items[] = new Zend_Pdf_Element_Numeric($y1);
  78. $rectangle->items[] = new Zend_Pdf_Element_Numeric($x2);
  79. $rectangle->items[] = new Zend_Pdf_Element_Numeric($y2);
  80. $annotationDictionary->Rect = $rectangle;
  81. $annotationDictionary->Contents = new Zend_Pdf_Element_String($text);
  82. return new Zend_Pdf_Annotation_Text($annotationDictionary);
  83. }
  84. }