composer package updates
[openemr.git] / vendor / mpdf / mpdf / src / Tag / FormFeed.php
blob6b2f46b17c593f21b2cc3ada195b7151af319aa5
1 <?php
3 namespace Mpdf\Tag;
5 class FormFeed extends Tag
7 public $toc_id;
9 public function open($attr, &$ahtml, &$ihtml)
11 $tag = $this->getTagName();
12 if (isset($attr['SHEET-SIZE'])) {
13 // Convert to same types as accepted in initial mPDF() A4, A4-L, or array(w,h)
14 $prop = preg_split('/\s+/', trim($attr['SHEET-SIZE']));
15 if (count($prop) == 2) {
16 $newformat = [$this->sizeConverter->convert($prop[0]), $this->sizeConverter->convert($prop[1])];
17 } else {
18 $newformat = $attr['SHEET-SIZE'];
20 } else {
21 $newformat = '';
24 $save_blklvl = $this->mpdf->blklvl;
25 $save_blk = $this->mpdf->blk;
26 $save_silp = $this->mpdf->saveInlineProperties();
27 $save_ilp = $this->mpdf->InlineProperties;
28 $save_bflp = $this->mpdf->InlineBDF;
29 $save_bflpc = $this->mpdf->InlineBDFctr; // mPDF 6
31 $mgr = $mgl = $mgt = $mgb = $mgh = $mgf = '';
32 if (isset($attr['MARGIN-RIGHT'])) {
33 $mgr = $this->sizeConverter->convert($attr['MARGIN-RIGHT'], $this->mpdf->w, $this->mpdf->FontSize, false);
35 if (isset($attr['MARGIN-LEFT'])) {
36 $mgl = $this->sizeConverter->convert($attr['MARGIN-LEFT'], $this->mpdf->w, $this->mpdf->FontSize, false);
38 if (isset($attr['MARGIN-TOP'])) {
39 $mgt = $this->sizeConverter->convert($attr['MARGIN-TOP'], $this->mpdf->w, $this->mpdf->FontSize, false);
41 if (isset($attr['MARGIN-BOTTOM'])) {
42 $mgb = $this->sizeConverter->convert($attr['MARGIN-BOTTOM'], $this->mpdf->w, $this->mpdf->FontSize, false);
44 if (isset($attr['MARGIN-HEADER'])) {
45 $mgh = $this->sizeConverter->convert($attr['MARGIN-HEADER'], $this->mpdf->w, $this->mpdf->FontSize, false);
47 if (isset($attr['MARGIN-FOOTER'])) {
48 $mgf = $this->sizeConverter->convert($attr['MARGIN-FOOTER'], $this->mpdf->w, $this->mpdf->FontSize, false);
50 $ohname = $ehname = $ofname = $efname = '';
51 if (isset($attr['ODD-HEADER-NAME'])) {
52 $ohname = $attr['ODD-HEADER-NAME'];
54 if (isset($attr['EVEN-HEADER-NAME'])) {
55 $ehname = $attr['EVEN-HEADER-NAME'];
57 if (isset($attr['ODD-FOOTER-NAME'])) {
58 $ofname = $attr['ODD-FOOTER-NAME'];
60 if (isset($attr['EVEN-FOOTER-NAME'])) {
61 $efname = $attr['EVEN-FOOTER-NAME'];
63 $ohvalue = $ehvalue = $ofvalue = $efvalue = 0;
64 if (isset($attr['ODD-HEADER-VALUE']) && ($attr['ODD-HEADER-VALUE'] == '1' || strtoupper($attr['ODD-HEADER-VALUE']) === 'ON')) {
65 $ohvalue = 1;
66 } elseif (isset($attr['ODD-HEADER-VALUE']) && ($attr['ODD-HEADER-VALUE'] == '-1' || strtoupper($attr['ODD-HEADER-VALUE']) === 'OFF')) {
67 $ohvalue = -1;
69 if (isset($attr['EVEN-HEADER-VALUE']) && ($attr['EVEN-HEADER-VALUE'] == '1' || strtoupper($attr['EVEN-HEADER-VALUE']) === 'ON')) {
70 $ehvalue = 1;
71 } elseif (isset($attr['EVEN-HEADER-VALUE']) && ($attr['EVEN-HEADER-VALUE'] == '-1' || strtoupper($attr['EVEN-HEADER-VALUE']) === 'OFF')) {
72 $ehvalue = -1;
74 if (isset($attr['ODD-FOOTER-VALUE']) && ($attr['ODD-FOOTER-VALUE'] == '1' || strtoupper($attr['ODD-FOOTER-VALUE']) === 'ON')) {
75 $ofvalue = 1;
76 } elseif (isset($attr['ODD-FOOTER-VALUE']) && ($attr['ODD-FOOTER-VALUE'] == '-1' || strtoupper($attr['ODD-FOOTER-VALUE']) === 'OFF')) {
77 $ofvalue = -1;
79 if (isset($attr['EVEN-FOOTER-VALUE']) && ($attr['EVEN-FOOTER-VALUE'] == '1' || strtoupper($attr['EVEN-FOOTER-VALUE']) === 'ON')) {
80 $efvalue = 1;
81 } elseif (isset($attr['EVEN-FOOTER-VALUE']) && ($attr['EVEN-FOOTER-VALUE'] == '-1' || strtoupper($attr['EVEN-FOOTER-VALUE']) === 'OFF')) {
82 $efvalue = -1;
85 if (isset($attr['ORIENTATION']) && (strtoupper($attr['ORIENTATION']) === 'L' || strtoupper($attr['ORIENTATION']) === 'LANDSCAPE')) {
86 $orient = 'L';
87 } elseif (isset($attr['ORIENTATION']) && (strtoupper($attr['ORIENTATION']) === 'P' || strtoupper($attr['ORIENTATION']) === 'PORTRAIT')) {
88 $orient = 'P';
89 } else {
90 $orient = $this->mpdf->CurOrientation;
93 $pagesel = '';
94 if (!empty($attr['PAGE-SELECTOR'])) {
95 $pagesel = $attr['PAGE-SELECTOR'];
98 // mPDF 6 pagebreaktype
99 $pagebreaktype = $this->mpdf->defaultPagebreakType;
100 if ($tag === 'FORMFEED') {
101 $pagebreaktype = 'slice';
102 } // can be overridden by PAGE-BREAK-TYPE
103 $startpage = $this->mpdf->page;
104 if (isset($attr['PAGE-BREAK-TYPE'])) {
105 if (strtolower($attr['PAGE-BREAK-TYPE']) === 'cloneall'
106 || strtolower($attr['PAGE-BREAK-TYPE']) === 'clonebycss'
107 || strtolower($attr['PAGE-BREAK-TYPE']) === 'slice') {
108 $pagebreaktype = strtolower($attr['PAGE-BREAK-TYPE']);
111 if ($tag === 'TOCPAGEBREAK') {
112 $pagebreaktype = 'cloneall';
113 } elseif ($this->mpdf->ColActive) {
114 $pagebreaktype = 'cloneall';
115 } // Any change in headers/footers (may need to _getHtmlHeight), or page size/orientation, @page selector, or margins - force cloneall
116 elseif ($mgr !== '' || $mgl !== '' || $mgt !== '' || $mgb !== '' || $mgh !== '' || $mgf !== '' ||
117 $ohname !== '' || $ehname !== '' || $ofname !== '' || $efname !== '' ||
118 $ohvalue || $ehvalue || $ofvalue || $efvalue ||
119 $orient != $this->mpdf->CurOrientation || $newformat || $pagesel) {
120 $pagebreaktype = 'cloneall';
123 // mPDF 6 pagebreaktype
124 $this->mpdf->_preForcedPagebreak($pagebreaktype);
126 $this->mpdf->ignorefollowingspaces = true;
129 $resetpagenum = '';
130 $pagenumstyle = '';
131 $suppress = '';
132 if (isset($attr['RESETPAGENUM'])) {
133 $resetpagenum = $attr['RESETPAGENUM'];
135 if (isset($attr['PAGENUMSTYLE'])) {
136 $pagenumstyle = $attr['PAGENUMSTYLE'];
138 if (isset($attr['SUPPRESS'])) {
139 $suppress = $attr['SUPPRESS'];
142 $type = '';
143 if ($tag === 'TOCPAGEBREAK') {
144 $type = 'NEXT-ODD';
145 } elseif (isset($attr['TYPE'])) {
146 $type = strtoupper($attr['TYPE']);
149 if ($type === 'E' || $type === 'EVEN') {
150 $this->mpdf->AddPage(
151 $orient,
152 'E',
153 $resetpagenum,
154 $pagenumstyle,
155 $suppress,
156 $mgl,
157 $mgr,
158 $mgt,
159 $mgb,
160 $mgh,
161 $mgf,
162 $ohname,
163 $ehname,
164 $ofname,
165 $efname,
166 $ohvalue,
167 $ehvalue,
168 $ofvalue,
169 $efvalue,
170 $pagesel,
171 $newformat
173 } elseif ($type === 'O' || $type === 'ODD') {
174 $this->mpdf->AddPage(
175 $orient,
176 'O',
177 $resetpagenum,
178 $pagenumstyle,
179 $suppress,
180 $mgl,
181 $mgr,
182 $mgt,
183 $mgb,
184 $mgh,
185 $mgf,
186 $ohname,
187 $ehname,
188 $ofname,
189 $efname,
190 $ohvalue,
191 $ehvalue,
192 $ofvalue,
193 $efvalue,
194 $pagesel,
195 $newformat
197 } elseif ($type === 'NEXT-ODD') {
198 $this->mpdf->AddPage(
199 $orient,
200 'NEXT-ODD',
201 $resetpagenum,
202 $pagenumstyle,
203 $suppress,
204 $mgl,
205 $mgr,
206 $mgt,
207 $mgb,
208 $mgh,
209 $mgf,
210 $ohname,
211 $ehname,
212 $ofname,
213 $efname,
214 $ohvalue,
215 $ehvalue,
216 $ofvalue,
217 $efvalue,
218 $pagesel,
219 $newformat
221 } elseif ($type === 'NEXT-EVEN') {
222 $this->mpdf->AddPage(
223 $orient,
224 'NEXT-EVEN',
225 $resetpagenum,
226 $pagenumstyle,
227 $suppress,
228 $mgl,
229 $mgr,
230 $mgt,
231 $mgb,
232 $mgh,
233 $mgf,
234 $ohname,
235 $ehname,
236 $ofname,
237 $efname,
238 $ohvalue,
239 $ehvalue,
240 $ofvalue,
241 $efvalue,
242 $pagesel,
243 $newformat
245 } else {
246 $this->mpdf->AddPage(
247 $orient,
249 $resetpagenum,
250 $pagenumstyle,
251 $suppress,
252 $mgl,
253 $mgr,
254 $mgt,
255 $mgb,
256 $mgh,
257 $mgf,
258 $ohname,
259 $ehname,
260 $ofname,
261 $efname,
262 $ohvalue,
263 $ehvalue,
264 $ofvalue,
265 $efvalue,
266 $pagesel,
267 $newformat
271 /* -- TOC -- */
272 if ($tag === 'TOCPAGEBREAK') {
273 if ($this->toc_id) {
274 $this->tableOfContents->m_TOC[$this->toc_id]['TOCmark'] = $this->mpdf->page;
275 } else {
276 $this->tableOfContents->TOCmark = $this->mpdf->page;
279 /* -- END TOC -- */
281 // mPDF 6 pagebreaktype
282 $this->mpdf->_postForcedPagebreak($pagebreaktype, $startpage, $save_blk, $save_blklvl);
284 $this->mpdf->InlineProperties = $save_ilp;
285 $this->mpdf->InlineBDF = $save_bflp;
286 $this->mpdf->InlineBDFctr = $save_bflpc; // mPDF 6
287 $this->mpdf->restoreInlineProperties($save_silp);
290 public function close(&$ahtml, &$ihtml)