12 var $TOCoutdent; // mPDF 5.6.31
28 var $TOC_margin_right;
32 var $TOC_margin_bottom;
34 var $TOC_margin_header;
36 var $TOC_margin_footer;
38 var $TOC_odd_header_name;
40 var $TOC_even_header_name;
42 var $TOC_odd_footer_name;
44 var $TOC_even_footer_name;
46 var $TOC_odd_header_value;
48 var $TOC_even_header_value;
50 var $TOC_odd_footer_value;
52 var $TOC_even_footer_value;
54 var $TOC_page_selector;
56 var $TOC_resetpagenum; // mPDF 6
58 var $TOC_pagenumstyle; // mPDF 6
60 var $TOC_suppress; // mPDF 6
64 public function __construct(mPDF
$mpdf)
67 $this->_toc
= array();
69 $this->m_TOC
= array();
72 function TOCpagebreak($tocfont = '', $tocfontsize = '', $tocindent = '', $TOCusePaging = true, $TOCuseLinking = '', $toc_orientation = '', $toc_mgl = '', $toc_mgr = '', $toc_mgt = '', $toc_mgb = '', $toc_mgh = '', $toc_mgf = '', $toc_ohname = '', $toc_ehname = '', $toc_ofname = '', $toc_efname = '', $toc_ohvalue = 0, $toc_ehvalue = 0, $toc_ofvalue = 0, $toc_efvalue = 0, $toc_preHTML = '', $toc_postHTML = '', $toc_bookmarkText = '', $resetpagenum = '', $pagenumstyle = '', $suppress = '', $orientation = '', $mgl = '', $mgr = '', $mgt = '', $mgb = '', $mgh = '', $mgf = '', $ohname = '', $ehname = '', $ofname = '', $efname = '', $ohvalue = 0, $ehvalue = 0, $ofvalue = 0, $efvalue = 0, $toc_id = 0, $pagesel = '', $toc_pagesel = '', $sheetsize = '', $toc_sheetsize = '', $tocoutdent = '', $toc_resetpagenum = '', $toc_pagenumstyle = '', $toc_suppress = '')
73 { // mPDF 5.6.19 // mPDF 6
74 if (strtoupper($toc_id) == 'ALL') {
75 $toc_id = '_mpdf_all';
76 } else if (!$toc_id) {
79 $toc_id = strtolower($toc_id);
82 if ($TOCusePaging === false ||
strtolower($TOCusePaging) == "off" ||
$TOCusePaging === 0 ||
$TOCusePaging === "0" ||
$TOCusePaging === "") {
83 $TOCusePaging = false;
87 if (!$TOCuseLinking) {
88 $TOCuseLinking = false;
91 $this->m_TOC
[$toc_id]['TOCmark'] = $this->mpdf
->page
;
92 $this->m_TOC
[$toc_id]['TOCoutdent'] = $tocoutdent;
93 $this->m_TOC
[$toc_id]['TOCorientation'] = $toc_orientation;
94 $this->m_TOC
[$toc_id]['TOCuseLinking'] = $TOCuseLinking;
95 $this->m_TOC
[$toc_id]['TOCusePaging'] = $TOCusePaging;
98 $this->m_TOC
[$toc_id]['TOCpreHTML'] = $toc_preHTML;
101 $this->m_TOC
[$toc_id]['TOCpostHTML'] = $toc_postHTML;
103 if ($toc_bookmarkText) {
104 $this->m_TOC
[$toc_id]['TOCbookmarkText'] = $toc_bookmarkText;
107 $this->m_TOC
[$toc_id]['TOC_margin_left'] = $toc_mgl;
108 $this->m_TOC
[$toc_id]['TOC_margin_right'] = $toc_mgr;
109 $this->m_TOC
[$toc_id]['TOC_margin_top'] = $toc_mgt;
110 $this->m_TOC
[$toc_id]['TOC_margin_bottom'] = $toc_mgb;
111 $this->m_TOC
[$toc_id]['TOC_margin_header'] = $toc_mgh;
112 $this->m_TOC
[$toc_id]['TOC_margin_footer'] = $toc_mgf;
113 $this->m_TOC
[$toc_id]['TOC_odd_header_name'] = $toc_ohname;
114 $this->m_TOC
[$toc_id]['TOC_even_header_name'] = $toc_ehname;
115 $this->m_TOC
[$toc_id]['TOC_odd_footer_name'] = $toc_ofname;
116 $this->m_TOC
[$toc_id]['TOC_even_footer_name'] = $toc_efname;
117 $this->m_TOC
[$toc_id]['TOC_odd_header_value'] = $toc_ohvalue;
118 $this->m_TOC
[$toc_id]['TOC_even_header_value'] = $toc_ehvalue;
119 $this->m_TOC
[$toc_id]['TOC_odd_footer_value'] = $toc_ofvalue;
120 $this->m_TOC
[$toc_id]['TOC_even_footer_value'] = $toc_efvalue;
121 $this->m_TOC
[$toc_id]['TOC_page_selector'] = $toc_pagesel;
122 $this->m_TOC
[$toc_id]['TOC_resetpagenum'] = $toc_resetpagenum; // mPDF 6
123 $this->m_TOC
[$toc_id]['TOC_pagenumstyle'] = $toc_pagenumstyle; // mPDF 6
124 $this->m_TOC
[$toc_id]['TOC_suppress'] = $toc_suppress; // mPDF 6
125 $this->m_TOC
[$toc_id]['TOCsheetsize'] = $toc_sheetsize;
127 $this->TOCmark
= $this->mpdf
->page
;
128 $this->TOCoutdent
= $tocoutdent;
129 $this->TOCorientation
= $toc_orientation;
130 $this->TOCuseLinking
= $TOCuseLinking;
131 $this->TOCusePaging
= $TOCusePaging;
134 $this->TOCpreHTML
= $toc_preHTML;
137 $this->TOCpostHTML
= $toc_postHTML;
139 if ($toc_bookmarkText) {
140 $this->TOCbookmarkText
= $toc_bookmarkText;
143 $this->TOC_margin_left
= $toc_mgl;
144 $this->TOC_margin_right
= $toc_mgr;
145 $this->TOC_margin_top
= $toc_mgt;
146 $this->TOC_margin_bottom
= $toc_mgb;
147 $this->TOC_margin_header
= $toc_mgh;
148 $this->TOC_margin_footer
= $toc_mgf;
149 $this->TOC_odd_header_name
= $toc_ohname;
150 $this->TOC_even_header_name
= $toc_ehname;
151 $this->TOC_odd_footer_name
= $toc_ofname;
152 $this->TOC_even_footer_name
= $toc_efname;
153 $this->TOC_odd_header_value
= $toc_ohvalue;
154 $this->TOC_even_header_value
= $toc_ehvalue;
155 $this->TOC_odd_footer_value
= $toc_ofvalue;
156 $this->TOC_even_footer_value
= $toc_efvalue;
157 $this->TOC_page_selector
= $toc_pagesel;
158 $this->TOC_resetpagenum
= $toc_resetpagenum; // mPDF 6
159 $this->TOC_pagenumstyle
= $toc_pagenumstyle; // mPDF 6
160 $this->TOC_suppress
= $toc_suppress; // mPDF 6
161 $this->TOCsheetsize
= $toc_sheetsize;
165 // Initiate, and Mark a place for the Table of Contents to be inserted
166 function TOC($tocfont = '', $tocfontsize = 0, $tocindent = 0, $resetpagenum = '', $pagenumstyle = '', $suppress = '', $toc_orientation = '', $TOCusePaging = true, $TOCuseLinking = false, $toc_id = 0, $tocoutdent = '', $toc_resetpagenum = '', $toc_pagenumstyle = '', $toc_suppress = '')
167 { // mPDF 5.6.19 // mPDF 6
168 if (strtoupper($toc_id) == 'ALL') {
169 $toc_id = '_mpdf_all';
170 } else if (!$toc_id) {
173 $toc_id = strtolower($toc_id);
175 // To use odd and even pages
176 // Cannot start table of contents on an even page
177 if (($this->mpdf
->mirrorMargins
) && (($this->mpdf
->page
) %
2 == 0)) { // EVEN
178 if ($this->mpdf
->ColActive
) {
179 if (count($this->mpdf
->columnbuffer
)) {
180 $this->mpdf
->printcolumnbuffer();
183 $this->mpdf
->AddPage($this->mpdf
->CurOrientation
, '', $resetpagenum, $pagenumstyle, $suppress);
185 $this->mpdf
->PageNumSubstitutions
[] = array('from' => $this->mpdf
->page
, 'reset' => $resetpagenum, 'type' => $pagenumstyle, 'suppress' => $suppress);
188 $this->m_TOC
[$toc_id]['TOCmark'] = $this->mpdf
->page
;
189 $this->m_TOC
[$toc_id]['TOCoutdent'] = $tocoutdent;
190 $this->m_TOC
[$toc_id]['TOCorientation'] = $toc_orientation;
191 $this->m_TOC
[$toc_id]['TOCuseLinking'] = $TOCuseLinking;
192 $this->m_TOC
[$toc_id]['TOCusePaging'] = $TOCusePaging;
193 $this->m_TOC
[$toc_id]['TOC_resetpagenum'] = $toc_resetpagenum; // mPDF 6
194 $this->m_TOC
[$toc_id]['TOC_pagenumstyle'] = $toc_pagenumstyle; // mPDF 6
195 $this->m_TOC
[$toc_id]['TOC_suppress'] = $toc_suppress; // mPDF 6
197 $this->TOCmark
= $this->mpdf
->page
;
198 $this->TOCoutdent
= $tocoutdent;
199 $this->TOCorientation
= $toc_orientation;
200 $this->TOCuseLinking
= $TOCuseLinking;
201 $this->TOCusePaging
= $TOCusePaging;
202 $this->TOC_resetpagenum
= $toc_resetpagenum; // mPDF 6
203 $this->TOC_pagenumstyle
= $toc_pagenumstyle; // mPDF 6
204 $this->TOC_suppress
= $toc_suppress; // mPDF 6
211 if ($this->TOCmark
) {
214 $notocs +
= count($this->m_TOC
);
220 if (count($this->m_TOC
)) {
223 $added_toc_pages = 0;
225 if ($this->mpdf
->ColActive
) {
226 $this->mpdf
->SetColumns(0);
228 if (($this->mpdf
->mirrorMargins
) && (($this->mpdf
->page
) %
2 == 1)) { // ODD
229 $this->mpdf
->AddPage($this->mpdf
->CurOrientation
);
235 for ($toci = 0; $toci < $notocs; $toci++
) {
236 if ($toci == 0 && $this->TOCmark
) {
238 $toc_page = $this->TOCmark
;
239 $tocoutdent = $this->TOCoutdent
;
240 $toc_orientation = $this->TOCorientation
;
241 $TOCuseLinking = $this->TOCuseLinking
;
242 $TOCusePaging = $this->TOCusePaging
;
243 $toc_preHTML = $this->TOCpreHTML
;
244 $toc_postHTML = $this->TOCpostHTML
;
245 $toc_bookmarkText = $this->TOCbookmarkText
;
246 $toc_mgl = $this->TOC_margin_left
;
247 $toc_mgr = $this->TOC_margin_right
;
248 $toc_mgt = $this->TOC_margin_top
;
249 $toc_mgb = $this->TOC_margin_bottom
;
250 $toc_mgh = $this->TOC_margin_header
;
251 $toc_mgf = $this->TOC_margin_footer
;
252 $toc_ohname = $this->TOC_odd_header_name
;
253 $toc_ehname = $this->TOC_even_header_name
;
254 $toc_ofname = $this->TOC_odd_footer_name
;
255 $toc_efname = $this->TOC_even_footer_name
;
256 $toc_ohvalue = $this->TOC_odd_header_value
;
257 $toc_ehvalue = $this->TOC_even_header_value
;
258 $toc_ofvalue = $this->TOC_odd_footer_value
;
259 $toc_efvalue = $this->TOC_even_footer_value
;
260 $toc_page_selector = $this->TOC_page_selector
;
261 $toc_resetpagenum = $this->TOC_resetpagenum
; // mPDF 6
262 $toc_pagenumstyle = $this->TOC_pagenumstyle
; // mPDF 6
263 $toc_suppress = $this->TOC_suppress
; // mPDF 6
264 $toc_sheet_size = (isset($this->TOCsheetsize
) ?
$this->TOCsheetsize
: '');
266 $arr = current($this->m_TOC
);
268 $toc_id = key($this->m_TOC
);
269 $toc_page = $this->m_TOC
[$toc_id]['TOCmark'];
270 $tocoutdent = $this->m_TOC
[$toc_id]['TOCoutdent'];
271 $toc_orientation = $this->m_TOC
[$toc_id]['TOCorientation'];
272 $TOCuseLinking = $this->m_TOC
[$toc_id]['TOCuseLinking'];
273 $TOCusePaging = $this->m_TOC
[$toc_id]['TOCusePaging'];
274 if (isset($this->m_TOC
[$toc_id]['TOCpreHTML'])) {
275 $toc_preHTML = $this->m_TOC
[$toc_id]['TOCpreHTML'];
279 if (isset($this->m_TOC
[$toc_id]['TOCpostHTML'])) {
280 $toc_postHTML = $this->m_TOC
[$toc_id]['TOCpostHTML'];
284 if (isset($this->m_TOC
[$toc_id]['TOCbookmarkText'])) {
285 $toc_bookmarkText = $this->m_TOC
[$toc_id]['TOCbookmarkText'];
287 $toc_bookmarkText = '';
289 $toc_mgl = $this->m_TOC
[$toc_id]['TOC_margin_left'];
290 $toc_mgr = $this->m_TOC
[$toc_id]['TOC_margin_right'];
291 $toc_mgt = $this->m_TOC
[$toc_id]['TOC_margin_top'];
292 $toc_mgb = $this->m_TOC
[$toc_id]['TOC_margin_bottom'];
293 $toc_mgh = $this->m_TOC
[$toc_id]['TOC_margin_header'];
294 $toc_mgf = $this->m_TOC
[$toc_id]['TOC_margin_footer'];
295 $toc_ohname = $this->m_TOC
[$toc_id]['TOC_odd_header_name'];
296 $toc_ehname = $this->m_TOC
[$toc_id]['TOC_even_header_name'];
297 $toc_ofname = $this->m_TOC
[$toc_id]['TOC_odd_footer_name'];
298 $toc_efname = $this->m_TOC
[$toc_id]['TOC_even_footer_name'];
299 $toc_ohvalue = $this->m_TOC
[$toc_id]['TOC_odd_header_value'];
300 $toc_ehvalue = $this->m_TOC
[$toc_id]['TOC_even_header_value'];
301 $toc_ofvalue = $this->m_TOC
[$toc_id]['TOC_odd_footer_value'];
302 $toc_efvalue = $this->m_TOC
[$toc_id]['TOC_even_footer_value'];
303 $toc_page_selector = $this->m_TOC
[$toc_id]['TOC_page_selector'];
304 $toc_resetpagenum = $this->m_TOC
[$toc_id]['TOC_resetpagenum']; // mPDF 6
305 $toc_pagenumstyle = $this->m_TOC
[$toc_id]['TOC_pagenumstyle']; // mPDF 6
306 $toc_suppress = $this->m_TOC
[$toc_id]['TOC_suppress']; // mPDF 6
307 $toc_sheet_size = (isset($this->m_TOC
[$toc_id]['TOCsheetsize']) ?
$this->m_TOC
[$toc_id]['TOCsheetsize'] : '');
312 if (!$toc_orientation) {
313 $toc_orientation = $this->mpdf
->DefOrientation
;
316 // mPDF 6 number style and suppress now picked up from section preceding ToC
317 list($tp_pagenumstyle, $tp_suppress, $tp_reset) = $this->mpdf
->docPageSettings($toc_page - 1);
319 if ($toc_resetpagenum)
320 $tp_reset = $toc_resetpagenum; // mPDF 6
321 if ($toc_pagenumstyle)
322 $tp_pagenumstyle = $toc_pagenumstyle; // mPDF 6
323 if ($toc_suppress ||
$toc_suppress === '0')
324 $tp_suppress = $toc_suppress; // mPDF 6
326 $this->mpdf
->AddPage($toc_orientation, '', $tp_reset, $tp_pagenumstyle, $tp_suppress, $toc_mgl, $toc_mgr, $toc_mgt, $toc_mgb, $toc_mgh, $toc_mgf, $toc_ohname, $toc_ehname, $toc_ofname, $toc_efname, $toc_ohvalue, $toc_ehvalue, $toc_ofvalue, $toc_efvalue, $toc_page_selector, $toc_sheet_size); // mPDF 6
329 $this->mpdf
->writingToC
= true; // mPDF 5.6.38
331 $tocstart = count($this->mpdf
->pages
);
332 if (isset($toc_preHTML) && $toc_preHTML) {
333 $this->mpdf
->WriteHTML($toc_preHTML);
338 $html = '<div class="mpdf_toc" id="mpdf_toc_' . $toc_id . '">';
339 foreach ($this->_toc
as $t) {
340 if ($t['toc_id'] === '_mpdf_all' ||
$t['toc_id'] === $toc_id) {
341 $html .= '<div class="mpdf_toc_level_' . $t['l'] . '">';
342 if ($TOCuseLinking) {
343 $html .= '<a class="mpdf_toc_a" href="#__mpdfinternallink_' . $t['link'] . '">';
345 $html .= '<span class="mpdf_toc_t_level_' . $t['l'] . '">' . $t['t'] . '</span>';
346 if ($TOCuseLinking) {
353 $html .= ' <dottab outdent="' . $tocoutdent . '" /> ';
354 if ($TOCuseLinking) {
355 $html .= '<a class="mpdf_toc_a" href="#__mpdfinternallink_' . $t['link'] . '">';
357 $html .= '<span class="mpdf_toc_p_level_' . $t['l'] . '">' . $this->mpdf
->docPageNum($t['p']) . '</span>';
358 if ($TOCuseLinking) {
366 $this->mpdf
->WriteHTML($html);
368 if (isset($toc_postHTML) && $toc_postHTML) {
369 $this->mpdf
->WriteHTML($toc_postHTML);
371 $this->mpdf
->writingToC
= false; // mPDF 5.6.38
372 $this->mpdf
->AddPage($toc_orientation, 'E');
374 $n_toc = $this->mpdf
->page
- $tocstart +
1;
376 if ($toci == 0 && $this->TOCmark
) {
377 $TOC_start = $tocstart;
378 $TOC_end = $this->mpdf
->page
;
379 $TOC_npages = $n_toc;
381 $this->m_TOC
[$toc_id]['start'] = $tocstart;
382 $this->m_TOC
[$toc_id]['end'] = $this->mpdf
->page
;
383 $this->m_TOC
[$toc_id]['npages'] = $n_toc;
389 $s .= $this->mpdf
->PrintBodyBackgrounds();
391 $s .= $this->mpdf
->PrintPageBackgrounds();
392 $this->mpdf
->pages
[$this->mpdf
->page
] = preg_replace('/(___BACKGROUND___PATTERNS' . $this->mpdf
->uniqstr
. ')/', "\n" . $s . "\n" . '\\1', $this->mpdf
->pages
[$this->mpdf
->page
]);
393 $this->mpdf
->pageBackgrounds
= array();
396 $this->mpdf
->InFooter
= true;
397 $this->mpdf
->Footer();
398 $this->mpdf
->InFooter
= false;
400 // 2nd time through to move pages etc.
401 $added_toc_pages = 0;
402 if (count($this->m_TOC
)) {
406 for ($toci = 0; $toci < $notocs; $toci++
) {
407 if ($toci == 0 && $this->TOCmark
) {
409 $toc_page = $this->TOCmark +
$added_toc_pages;
410 $toc_orientation = $this->TOCorientation
;
411 $TOCuseLinking = $this->TOCuseLinking
;
412 $TOCusePaging = $this->TOCusePaging
;
413 $toc_bookmarkText = $this->TOCbookmarkText
; // *BOOKMARKS*
415 $tocstart = $TOC_start;
416 $tocend = $n = $TOC_end;
417 $n_toc = $TOC_npages;
419 $arr = current($this->m_TOC
);
421 $toc_id = key($this->m_TOC
);
422 $toc_page = $this->m_TOC
[$toc_id]['TOCmark'] +
$added_toc_pages;
423 $toc_orientation = $this->m_TOC
[$toc_id]['TOCorientation'];
424 $TOCuseLinking = $this->m_TOC
[$toc_id]['TOCuseLinking'];
425 $TOCusePaging = $this->m_TOC
[$toc_id]['TOCusePaging'];
426 $toc_bookmarkText = $this->m_TOC
[$toc_id]['TOCbookmarkText']; // *BOOKMARKS*
428 $tocstart = $this->m_TOC
[$toc_id]['start'];
429 $tocend = $n = $this->m_TOC
[$toc_id]['end'];
430 $n_toc = $this->m_TOC
[$toc_id]['npages'];
436 $added_toc_pages +
= $n_toc;
438 $this->mpdf
->MovePages($toc_page, $tocstart, $tocend);
439 $this->mpdf
->pgsIns
[$toc_page] = $tocend - $tocstart +
1;
441 /* -- BOOKMARKS -- */
442 // Insert new Bookmark for Bookmark
443 if ($toc_bookmarkText) {
445 foreach ($this->mpdf
->BMoutlines
as $i => $o) {
446 if ($o['p'] < $toc_page) { // i.e. before point of insertion
450 $txt = $this->mpdf
->purify_utf8_text($toc_bookmarkText);
451 if ($this->mpdf
->text_input_as_HTML
) {
452 $txt = $this->mpdf
->all_entities_to_utf8($txt);
454 $newBookmark[0] = array('t' => $txt, 'l' => 0, 'y' => 0, 'p' => $toc_page);
455 array_splice($this->mpdf
->BMoutlines
, ($insert +
1), 0, $newBookmark);
457 /* -- END BOOKMARKS -- */
460 // Delete empty page that was inserted earlier
462 unset($this->mpdf
->pages
[count($this->mpdf
->pages
)]);
463 $this->mpdf
->page
--; // Reset page pointer
467 function openTagTOC($attr)
469 if (isset($attr['OUTDENT']) && $attr['OUTDENT']) {
470 $tocoutdent = $attr['OUTDENT'];
474 if (isset($attr['RESETPAGENUM']) && $attr['RESETPAGENUM']) {
475 $resetpagenum = $attr['RESETPAGENUM'];
479 if (isset($attr['PAGENUMSTYLE']) && $attr['PAGENUMSTYLE']) {
480 $pagenumstyle = $attr['PAGENUMSTYLE'];
484 if (isset($attr['SUPPRESS']) && $attr['SUPPRESS']) {
485 $suppress = $attr['SUPPRESS'];
489 if (isset($attr['TOC-ORIENTATION']) && $attr['TOC-ORIENTATION']) {
490 $toc_orientation = $attr['TOC-ORIENTATION'];
492 $toc_orientation = '';
494 if (isset($attr['PAGING']) && (strtoupper($attr['PAGING']) == 'OFF' ||
$attr['PAGING'] === '0')) {
499 if (isset($attr['LINKS']) && (strtoupper($attr['LINKS']) == 'ON' ||
$attr['LINKS'] == 1)) {
504 if (isset($attr['NAME']) && $attr['NAME']) {
505 $toc_id = strtolower($attr['NAME']);
509 $this->TOC('', 0, 0, $resetpagenum, $pagenumstyle, $suppress, $toc_orientation, $paging, $links, $toc_id, $tocoutdent); // mPDF 5.6.19 5.6.31
512 function openTagTOCPAGEBREAK($attr)
514 if (isset($attr['NAME']) && $attr['NAME']) {
515 $toc_id = strtolower($attr['NAME']);
520 if (isset($attr['OUTDENT']) && $attr['OUTDENT']) {
521 $this->m_TOC
[$toc_id]['TOCoutdent'] = $attr['OUTDENT'];
523 $this->m_TOC
[$toc_id]['TOCoutdent'] = '';
525 if (isset($attr['TOC-ORIENTATION']) && $attr['TOC-ORIENTATION']) {
526 $this->m_TOC
[$toc_id]['TOCorientation'] = $attr['TOC-ORIENTATION'];
528 $this->m_TOC
[$toc_id]['TOCorientation'] = '';
530 if (isset($attr['PAGING']) && (strtoupper($attr['PAGING']) == 'OFF' ||
$attr['PAGING'] === '0')) {
531 $this->m_TOC
[$toc_id]['TOCusePaging'] = false;
533 $this->m_TOC
[$toc_id]['TOCusePaging'] = true;
535 if (isset($attr['LINKS']) && (strtoupper($attr['LINKS']) == 'ON' ||
$attr['LINKS'] == 1)) {
536 $this->m_TOC
[$toc_id]['TOCuseLinking'] = true;
538 $this->m_TOC
[$toc_id]['TOCuseLinking'] = false;
541 $this->m_TOC
[$toc_id]['TOC_margin_left'] = $this->m_TOC
[$toc_id]['TOC_margin_right'] = $this->m_TOC
[$toc_id]['TOC_margin_top'] = $this->m_TOC
[$toc_id]['TOC_margin_bottom'] = $this->m_TOC
[$toc_id]['TOC_margin_header'] = $this->m_TOC
[$toc_id]['TOC_margin_footer'] = '';
542 if (isset($attr['TOC-MARGIN-RIGHT'])) {
543 $this->m_TOC
[$toc_id]['TOC_margin_right'] = $this->mpdf
->ConvertSize($attr['TOC-MARGIN-RIGHT'], $this->mpdf
->w
, $this->mpdf
->FontSize
, false);
545 if (isset($attr['TOC-MARGIN-LEFT'])) {
546 $this->m_TOC
[$toc_id]['TOC_margin_left'] = $this->mpdf
->ConvertSize($attr['TOC-MARGIN-LEFT'], $this->mpdf
->w
, $this->mpdf
->FontSize
, false);
548 if (isset($attr['TOC-MARGIN-TOP'])) {
549 $this->m_TOC
[$toc_id]['TOC_margin_top'] = $this->mpdf
->ConvertSize($attr['TOC-MARGIN-TOP'], $this->mpdf
->w
, $this->mpdf
->FontSize
, false);
551 if (isset($attr['TOC-MARGIN-BOTTOM'])) {
552 $this->m_TOC
[$toc_id]['TOC_margin_bottom'] = $this->mpdf
->ConvertSize($attr['TOC-MARGIN-BOTTOM'], $this->mpdf
->w
, $this->mpdf
->FontSize
, false);
554 if (isset($attr['TOC-MARGIN-HEADER'])) {
555 $this->m_TOC
[$toc_id]['TOC_margin_header'] = $this->mpdf
->ConvertSize($attr['TOC-MARGIN-HEADER'], $this->mpdf
->w
, $this->mpdf
->FontSize
, false);
557 if (isset($attr['TOC-MARGIN-FOOTER'])) {
558 $this->m_TOC
[$toc_id]['TOC_margin_footer'] = $this->mpdf
->ConvertSize($attr['TOC-MARGIN-FOOTER'], $this->mpdf
->w
, $this->mpdf
->FontSize
, false);
560 $this->m_TOC
[$toc_id]['TOC_odd_header_name'] = $this->m_TOC
[$toc_id]['TOC_even_header_name'] = $this->m_TOC
[$toc_id]['TOC_odd_footer_name'] = $this->m_TOC
[$toc_id]['TOC_even_footer_name'] = '';
561 if (isset($attr['TOC-ODD-HEADER-NAME']) && $attr['TOC-ODD-HEADER-NAME']) {
562 $this->m_TOC
[$toc_id]['TOC_odd_header_name'] = $attr['TOC-ODD-HEADER-NAME'];
564 if (isset($attr['TOC-EVEN-HEADER-NAME']) && $attr['TOC-EVEN-HEADER-NAME']) {
565 $this->m_TOC
[$toc_id]['TOC_even_header_name'] = $attr['TOC-EVEN-HEADER-NAME'];
567 if (isset($attr['TOC-ODD-FOOTER-NAME']) && $attr['TOC-ODD-FOOTER-NAME']) {
568 $this->m_TOC
[$toc_id]['TOC_odd_footer_name'] = $attr['TOC-ODD-FOOTER-NAME'];
570 if (isset($attr['TOC-EVEN-FOOTER-NAME']) && $attr['TOC-EVEN-FOOTER-NAME']) {
571 $this->m_TOC
[$toc_id]['TOC_even_footer_name'] = $attr['TOC-EVEN-FOOTER-NAME'];
573 $this->m_TOC
[$toc_id]['TOC_odd_header_value'] = $this->m_TOC
[$toc_id]['TOC_even_header_value'] = $this->m_TOC
[$toc_id]['TOC_odd_footer_value'] = $this->m_TOC
[$toc_id]['TOC_even_footer_value'] = 0;
574 if (isset($attr['TOC-ODD-HEADER-VALUE']) && ($attr['TOC-ODD-HEADER-VALUE'] == '1' ||
strtoupper($attr['TOC-ODD-HEADER-VALUE']) == 'ON')) {
575 $this->m_TOC
[$toc_id]['TOC_odd_header_value'] = 1;
576 } else if (isset($attr['TOC-ODD-HEADER-VALUE']) && ($attr['TOC-ODD-HEADER-VALUE'] == '-1' ||
strtoupper($attr['TOC-ODD-HEADER-VALUE']) == 'OFF')) {
577 $this->m_TOC
[$toc_id]['TOC_odd_header_value'] = -1;
579 if (isset($attr['TOC-EVEN-HEADER-VALUE']) && ($attr['TOC-EVEN-HEADER-VALUE'] == '1' ||
strtoupper($attr['TOC-EVEN-HEADER-VALUE']) == 'ON')) {
580 $this->m_TOC
[$toc_id]['TOC_even_header_value'] = 1;
581 } else if (isset($attr['TOC-EVEN-HEADER-VALUE']) && ($attr['TOC-EVEN-HEADER-VALUE'] == '-1' ||
strtoupper($attr['TOC-EVEN-HEADER-VALUE']) == 'OFF')) {
582 $this->m_TOC
[$toc_id]['TOC_even_header_value'] = -1;
584 if (isset($attr['TOC-ODD-FOOTER-VALUE']) && ($attr['TOC-ODD-FOOTER-VALUE'] == '1' ||
strtoupper($attr['TOC-ODD-FOOTER-VALUE']) == 'ON')) {
585 $this->m_TOC
[$toc_id]['TOC_odd_footer_value'] = 1;
586 } else if (isset($attr['TOC-ODD-FOOTER-VALUE']) && ($attr['TOC-ODD-FOOTER-VALUE'] == '-1' ||
strtoupper($attr['TOC-ODD-FOOTER-VALUE']) == 'OFF')) {
587 $this->m_TOC
[$toc_id]['TOC_odd_footer_value'] = -1;
589 if (isset($attr['TOC-EVEN-FOOTER-VALUE']) && ($attr['TOC-EVEN-FOOTER-VALUE'] == '1' ||
strtoupper($attr['TOC-EVEN-FOOTER-VALUE']) == 'ON')) {
590 $this->m_TOC
[$toc_id]['TOC_even_footer_value'] = 1;
591 } else if (isset($attr['TOC-EVEN-FOOTER-VALUE']) && ($attr['TOC-EVEN-FOOTER-VALUE'] == '-1' ||
strtoupper($attr['TOC-EVEN-FOOTER-VALUE']) == 'OFF')) {
592 $this->m_TOC
[$toc_id]['TOC_even_footer_value'] = -1;
594 if (isset($attr['TOC-RESETPAGENUM']) && $attr['TOC-RESETPAGENUM']) {
595 $this->m_TOC
[$toc_id]['TOC_resetpagenum'] = $attr['TOC-RESETPAGENUM'];
597 $this->m_TOC
[$toc_id]['TOC_resetpagenum'] = '';
599 if (isset($attr['TOC-PAGENUMSTYLE']) && $attr['TOC-PAGENUMSTYLE']) {
600 $this->m_TOC
[$toc_id]['TOC_pagenumstyle'] = $attr['TOC-PAGENUMSTYLE'];
602 $this->m_TOC
[$toc_id]['TOC_pagenumstyle'] = '';
604 if (isset($attr['TOC-SUPPRESS']) && ($attr['TOC-SUPPRESS'] ||
$attr['TOC-SUPPRESS'] === '0')) {
605 $this->m_TOC
[$toc_id]['TOC_suppress'] = $attr['TOC-SUPPRESS'];
607 $this->m_TOC
[$toc_id]['TOC_suppress'] = '';
609 if (isset($attr['TOC-PAGE-SELECTOR']) && $attr['TOC-PAGE-SELECTOR']) {
610 $this->m_TOC
[$toc_id]['TOC_page_selector'] = $attr['TOC-PAGE-SELECTOR'];
612 $this->m_TOC
[$toc_id]['TOC_page_selector'] = '';
614 if (isset($attr['TOC-SHEET-SIZE']) && $attr['TOC-SHEET-SIZE']) {
615 $this->m_TOC
[$toc_id]['TOCsheetsize'] = $attr['TOC-SHEET-SIZE'];
617 $this->m_TOC
[$toc_id]['TOCsheetsize'] = '';
621 if (isset($attr['TOC-PREHTML']) && $attr['TOC-PREHTML']) {
622 $this->m_TOC
[$toc_id]['TOCpreHTML'] = htmlspecialchars_decode($attr['TOC-PREHTML'], ENT_QUOTES
);
624 if (isset($attr['TOC-POSTHTML']) && $attr['TOC-POSTHTML']) {
625 $this->m_TOC
[$toc_id]['TOCpostHTML'] = htmlspecialchars_decode($attr['TOC-POSTHTML'], ENT_QUOTES
);
628 if (isset($attr['TOC-BOOKMARKTEXT']) && $attr['TOC-BOOKMARKTEXT']) {
629 $this->m_TOC
[$toc_id]['TOCbookmarkText'] = htmlspecialchars_decode($attr['TOC-BOOKMARKTEXT'], ENT_QUOTES
);
632 if (isset($attr['OUTDENT']) && $attr['OUTDENT']) {
633 $this->TOCoutdent
= $attr['OUTDENT'];
635 $this->TOCoutdent
= '';
637 if (isset($attr['TOC-ORIENTATION']) && $attr['TOC-ORIENTATION']) {
638 $this->TOCorientation
= $attr['TOC-ORIENTATION'];
640 $this->TOCorientation
= '';
642 if (isset($attr['PAGING']) && (strtoupper($attr['PAGING']) == 'OFF' ||
$attr['PAGING'] === '0')) {
643 $this->TOCusePaging
= false;
645 $this->TOCusePaging
= true;
647 if (isset($attr['LINKS']) && (strtoupper($attr['LINKS']) == 'ON' ||
$attr['LINKS'] == 1)) {
648 $this->TOCuseLinking
= true;
650 $this->TOCuseLinking
= false;
653 $this->TOC_margin_left
= $this->TOC_margin_right
= $this->TOC_margin_top
= $this->TOC_margin_bottom
= $this->TOC_margin_header
= $this->TOC_margin_footer
= '';
654 if (isset($attr['TOC-MARGIN-RIGHT'])) {
655 $this->TOC_margin_right
= $this->mpdf
->ConvertSize($attr['TOC-MARGIN-RIGHT'], $this->mpdf
->w
, $this->mpdf
->FontSize
, false);
657 if (isset($attr['TOC-MARGIN-LEFT'])) {
658 $this->TOC_margin_left
= $this->mpdf
->ConvertSize($attr['TOC-MARGIN-LEFT'], $this->mpdf
->w
, $this->mpdf
->FontSize
, false);
660 if (isset($attr['TOC-MARGIN-TOP'])) {
661 $this->TOC_margin_top
= $this->mpdf
->ConvertSize($attr['TOC-MARGIN-TOP'], $this->mpdf
->w
, $this->mpdf
->FontSize
, false);
663 if (isset($attr['TOC-MARGIN-BOTTOM'])) {
664 $this->TOC_margin_bottom
= $this->mpdf
->ConvertSize($attr['TOC-MARGIN-BOTTOM'], $this->mpdf
->w
, $this->mpdf
->FontSize
, false);
666 if (isset($attr['TOC-MARGIN-HEADER'])) {
667 $this->TOC_margin_header
= $this->mpdf
->ConvertSize($attr['TOC-MARGIN-HEADER'], $this->mpdf
->w
, $this->mpdf
->FontSize
, false);
669 if (isset($attr['TOC-MARGIN-FOOTER'])) {
670 $this->TOC_margin_footer
= $this->mpdf
->ConvertSize($attr['TOC-MARGIN-FOOTER'], $this->mpdf
->w
, $this->mpdf
->FontSize
, false);
672 $this->TOC_odd_header_name
= $this->TOC_even_header_name
= $this->TOC_odd_footer_name
= $this->TOC_even_footer_name
= '';
673 if (isset($attr['TOC-ODD-HEADER-NAME']) && $attr['TOC-ODD-HEADER-NAME']) {
674 $this->TOC_odd_header_name
= $attr['TOC-ODD-HEADER-NAME'];
676 if (isset($attr['TOC-EVEN-HEADER-NAME']) && $attr['TOC-EVEN-HEADER-NAME']) {
677 $this->TOC_even_header_name
= $attr['TOC-EVEN-HEADER-NAME'];
679 if (isset($attr['TOC-ODD-FOOTER-NAME']) && $attr['TOC-ODD-FOOTER-NAME']) {
680 $this->TOC_odd_footer_name
= $attr['TOC-ODD-FOOTER-NAME'];
682 if (isset($attr['TOC-EVEN-FOOTER-NAME']) && $attr['TOC-EVEN-FOOTER-NAME']) {
683 $this->TOC_even_footer_name
= $attr['TOC-EVEN-FOOTER-NAME'];
685 $this->TOC_odd_header_value
= $this->TOC_even_header_value
= $this->TOC_odd_footer_value
= $this->TOC_even_footer_value
= 0;
686 if (isset($attr['TOC-ODD-HEADER-VALUE']) && ($attr['TOC-ODD-HEADER-VALUE'] == '1' ||
strtoupper($attr['TOC-ODD-HEADER-VALUE']) == 'ON')) {
687 $this->TOC_odd_header_value
= 1;
688 } else if (isset($attr['TOC-ODD-HEADER-VALUE']) && ($attr['TOC-ODD-HEADER-VALUE'] == '-1' ||
strtoupper($attr['TOC-ODD-HEADER-VALUE']) == 'OFF')) {
689 $this->TOC_odd_header_value
= -1;
691 if (isset($attr['TOC-EVEN-HEADER-VALUE']) && ($attr['TOC-EVEN-HEADER-VALUE'] == '1' ||
strtoupper($attr['TOC-EVEN-HEADER-VALUE']) == 'ON')) {
692 $this->TOC_even_header_value
= 1;
693 } else if (isset($attr['TOC-EVEN-HEADER-VALUE']) && ($attr['TOC-EVEN-HEADER-VALUE'] == '-1' ||
strtoupper($attr['TOC-EVEN-HEADER-VALUE']) == 'OFF')) {
694 $this->TOC_even_header_value
= -1;
697 if (isset($attr['TOC-ODD-FOOTER-VALUE']) && ($attr['TOC-ODD-FOOTER-VALUE'] == '1' ||
strtoupper($attr['TOC-ODD-FOOTER-VALUE']) == 'ON')) {
698 $this->TOC_odd_footer_value
= 1;
699 } else if (isset($attr['TOC-ODD-FOOTER-VALUE']) && ($attr['TOC-ODD-FOOTER-VALUE'] == '-1' ||
strtoupper($attr['TOC-ODD-FOOTER-VALUE']) == 'OFF')) {
700 $this->TOC_odd_footer_value
= -1;
702 if (isset($attr['TOC-EVEN-FOOTER-VALUE']) && ($attr['TOC-EVEN-FOOTER-VALUE'] == '1' ||
strtoupper($attr['TOC-EVEN-FOOTER-VALUE']) == 'ON')) {
703 $this->TOC_even_footer_value
= 1;
704 } else if (isset($attr['TOC-EVEN-FOOTER-VALUE']) && ($attr['TOC-EVEN-FOOTER-VALUE'] == '-1' ||
strtoupper($attr['TOC-EVEN-FOOTER-VALUE']) == 'OFF')) {
705 $this->TOC_even_footer_value
= -1;
707 if (isset($attr['TOC-PAGE-SELECTOR']) && $attr['TOC-PAGE-SELECTOR']) {
708 $this->TOC_page_selector
= $attr['TOC-PAGE-SELECTOR'];
710 $this->TOC_page_selector
= '';
712 if (isset($attr['TOC-RESETPAGENUM']) && $attr['TOC-RESETPAGENUM']) {
713 $this->TOC_resetpagenum
= $attr['TOC-RESETPAGENUM'];
715 $this->TOC_resetpagenum
= '';
717 if (isset($attr['TOC-PAGENUMSTYLE']) && $attr['TOC-PAGENUMSTYLE']) {
718 $this->TOC_pagenumstyle
= $attr['TOC-PAGENUMSTYLE'];
720 $this->TOC_pagenumstyle
= '';
722 if (isset($attr['TOC-SUPPRESS']) && ($attr['TOC-SUPPRESS'] ||
$attr['TOC-SUPPRESS'] === '0')) {
723 $this->TOC_suppress
= $attr['TOC-SUPPRESS'];
725 $this->TOC_suppress
= '';
727 if (isset($attr['TOC-SHEET-SIZE']) && $attr['TOC-SHEET-SIZE']) {
728 $this->TOCsheetsize
= $attr['TOC-SHEET-SIZE'];
730 $this->TOCsheetsize
= '';
733 if (isset($attr['TOC-PREHTML']) && $attr['TOC-PREHTML']) {
734 $this->TOCpreHTML
= htmlspecialchars_decode($attr['TOC-PREHTML'], ENT_QUOTES
);
736 if (isset($attr['TOC-POSTHTML']) && $attr['TOC-POSTHTML']) {
737 $this->TOCpostHTML
= htmlspecialchars_decode($attr['TOC-POSTHTML'], ENT_QUOTES
);
739 if (isset($attr['TOC-BOOKMARKTEXT']) && $attr['TOC-BOOKMARKTEXT']) {
740 $this->TOCbookmarkText
= htmlspecialchars_decode($attr['TOC-BOOKMARKTEXT'], ENT_QUOTES
);
744 if ($this->mpdf
->y
== $this->mpdf
->tMargin
&& (!$this->mpdf
->mirrorMargins ||
($this->mpdf
->mirrorMargins
&& $this->mpdf
->page %
2 == 1))) {
746 $this->m_TOC
[$toc_id]['TOCmark'] = $this->mpdf
->page
;
748 $this->TOCmark
= $this->mpdf
->page
;
751 if ($this->mpdf
->page
== 1 && count($this->mpdf
->PageNumSubstitutions
) == 0) {
755 if (isset($attr['RESETPAGENUM'])) {
756 $resetpagenum = $attr['RESETPAGENUM'];
758 if (isset($attr['PAGENUMSTYLE'])) {
759 $pagenumstyle = $attr['PAGENUMSTYLE'];
761 if (isset($attr['SUPPRESS'])) {
762 $suppress = $attr['SUPPRESS'];
767 if (!$resetpagenum) {
770 $this->mpdf
->PageNumSubstitutions
[] = array('from' => 1, 'reset' => $resetpagenum, 'type' => $pagenumstyle, 'suppress' => $suppress);
772 return array(true, $toc_id);
774 // No break - continues as PAGEBREAK...
775 return array(false, $toc_id);