1<?php
2
3namespace Mpdf\Tag;
4
5class Annotation extends Tag
6{
7
8	public function open($attr, &$ahtml, &$ihtml)
9	{
10		//if (isset($attr['CONTENT']) && !$this->mpdf->writingHTMLheader && !$this->mpdf->writingHTMLfooter) {	// Stops annotations in FixedPos
11		if (isset($attr['CONTENT'])) {
12			$objattr = [];
13			$objattr['margin_top'] = 0;
14			$objattr['margin_bottom'] = 0;
15			$objattr['margin_left'] = 0;
16			$objattr['margin_right'] = 0;
17			$objattr['width'] = 0;
18			$objattr['height'] = 0;
19			$objattr['border_top']['w'] = 0;
20			$objattr['border_bottom']['w'] = 0;
21			$objattr['border_left']['w'] = 0;
22			$objattr['border_right']['w'] = 0;
23			$objattr['CONTENT'] = htmlspecialchars_decode($attr['CONTENT'], ENT_QUOTES);
24			$objattr['type'] = 'annot';
25			$objattr['POPUP'] = '';
26		} else {
27			return;
28		}
29		if (isset($attr['POS-X'])) {
30			$objattr['POS-X'] = $attr['POS-X'];
31		} else {
32			$objattr['POS-X'] = 0;
33		}
34		if (isset($attr['POS-Y'])) {
35			$objattr['POS-Y'] = $attr['POS-Y'];
36		} else {
37			$objattr['POS-Y'] = 0;
38		}
39		if (isset($attr['ICON'])) {
40			$objattr['ICON'] = $attr['ICON'];
41		} else {
42			$objattr['ICON'] = 'Note';
43		}
44		if (isset($attr['AUTHOR'])) {
45			$objattr['AUTHOR'] = $attr['AUTHOR'];
46		} elseif (isset($attr['TITLE'])) {
47			$objattr['AUTHOR'] = $attr['TITLE'];
48		} else {
49			$objattr['AUTHOR'] = '';
50		}
51		if (isset($attr['FILE'])) {
52			$objattr['FILE'] = $attr['FILE'];
53		} else {
54			$objattr['FILE'] = '';
55		}
56		if (isset($attr['SUBJECT'])) {
57			$objattr['SUBJECT'] = $attr['SUBJECT'];
58		} else {
59			$objattr['SUBJECT'] = '';
60		}
61		if (isset($attr['OPACITY']) && $attr['OPACITY'] > 0 && $attr['OPACITY'] <= 1) {
62			$objattr['OPACITY'] = $attr['OPACITY'];
63		} elseif ($this->mpdf->annotMargin) {
64			$objattr['OPACITY'] = 1;
65		} else {
66			$objattr['OPACITY'] = $this->mpdf->annotOpacity;
67		}
68		if (isset($attr['COLOR'])) {
69			$cor = $this->colorConverter->convert($attr['COLOR'], $this->mpdf->PDFAXwarnings);
70			if ($cor) {
71				$objattr['COLOR'] = $cor;
72			} else {
73				$objattr['COLOR'] = $this->colorConverter->convert('yellow', $this->mpdf->PDFAXwarnings);
74			}
75		} else {
76			$objattr['COLOR'] = $this->colorConverter->convert('yellow', $this->mpdf->PDFAXwarnings);
77		}
78
79		if (isset($attr['POPUP']) && !empty($attr['POPUP'])) {
80			$pop = preg_split('/\s+/', trim($attr['POPUP']));
81			if (count($pop) > 1) {
82				$objattr['POPUP'] = $pop;
83			} else {
84				$objattr['POPUP'] = true;
85			}
86		}
87		$e = "\xbb\xa4\xactype=annot,objattr=" . serialize($objattr) . "\xbb\xa4\xac";
88		if ($this->mpdf->tableLevel) {
89			$this->mpdf->cell[$this->mpdf->row][$this->mpdf->col]['textbuffer'][] = [$e];
90		} // *TABLES*
91		else { // *TABLES*
92			$this->mpdf->textbuffer[] = [$e];
93		} // *TABLES*
94	}
95
96	public function close(&$ahtml, &$ihtml)
97	{
98	}
99}
100