1: <?php
2:
3: namespace WkHtmlToPdf\Options;
4:
5: use WkHtmlToPdf\WkHtmlToPdf;
6:
7: /**
8: * @author ivanpepelko
9: */
10: trait TocOptionsTrait
11: {
12: /**
13: * Do not use dotted lines in the toc.
14: *
15: * @return WkHtmlToPdf
16: */
17: public function disableTocDottedLines()
18: {
19: $this->arguments['disable-dotted-lines'] = null;
20:
21: return $this;
22: }
23:
24: /**
25: * Use dotted lines in the toc (if dotted lines are present in html).
26: *
27: * @return WkHtmlToPdf
28: */
29: public function enableTocDottedLines()
30: {
31: if (array_key_exists('disable-dotted-lines', $this->arguments)) {
32: unset($this->arguments['disable-dotted-lines']);
33: }
34:
35: return $this;
36: }
37:
38: /**
39: * The header text of the toc (default 'Table of Contents').
40: *
41: * @param string $text
42: *
43: * @return WkHtmlToPdf
44: */
45: public function setTocHeaderText($text = 'Table of Contents')
46: {
47: $this->arguments['toc-header-text'] = $text;
48:
49: return $this;
50: }
51:
52: /**
53: * For each level of headings in the toc indent by this length (default 1em).
54: *
55: * @param string $width
56: *
57: * @return WkHtmlToPdf
58: */
59: public function setTocLevelIndentation($width = '1em')
60: {
61: $this->arguments['toc-level-indentation'] = $width;
62:
63: return $this;
64: }
65:
66: /**
67: * Do not link from toc to sections.
68: *
69: * @return WkHtmlToPdf
70: */
71: public function disableTocLinks()
72: {
73: $this->arguments['disable-toc-links'] = null;
74:
75: return $this;
76: }
77:
78: /**
79: * Link from toc to sections (only if it was disabled by disableTocLinks()).
80: *
81: * @return WkHtmlToPdf
82: */
83: public function enableTocLinks()
84: {
85: if (array_key_exists('disable-toc-links', $this->arguments)) {
86: unset($this->arguments['disable-toc-links']);
87: }
88:
89: return $this;
90: }
91:
92: /**
93: * For each level of headings in the toc the font is scaled by this factor (default 0.8).
94: *
95: * @param float $factor
96: *
97: * @return WkHtmlToPdf
98: */
99: public function setTocTextSizeShrinking($factor = 0.8)
100: {
101: $this->arguments['toc-text-size-shrink'] = $factor;
102:
103: return $this;
104: }
105:
106: /**
107: * Use the supplied xsl style sheet for printing the table of content.
108: *
109: * @param string $path Path to xsl style sheet
110: *
111: * @return WkHtmlToPdf
112: */
113: public function setTocXslStyleSheet($path)
114: {
115: $this->arguments['xsl-style-sheet'] = $path;
116:
117: return $this;
118: }
119: }
120: