Overview

Namespaces

  • None
  • PHP
  • WkHtmlToPdf
    • Options

Classes

  • WkHtmlToPdf\WkHtmlToPdf

Interfaces

  • Throwable

Traits

  • WkHtmlToPdf\Options\GlobalOptionsTrait
  • WkHtmlToPdf\Options\HeaderFooterOptionsTrait
  • WkHtmlToPdf\Options\OutlineOptionsTrait
  • WkHtmlToPdf\Options\PageOptionsTrait
  • WkHtmlToPdf\Options\TocOptionsTrait

Exceptions

  • Exception

Functions

  • join_path
  • Overview
  • Namespace
  • Class
  • Tree
  1: <?php
  2: 
  3: namespace WkHtmlToPdf\Options;
  4: 
  5: use WkHtmlToPdf\WkHtmlToPdf;
  6: 
  7: /**
  8:  * @author ivanpepelko
  9:  */
 10: trait HeaderFooterOptionsTrait
 11: {
 12:     /**
 13:      * Centered footer text.
 14:      *
 15:      * @param string $text
 16:      *
 17:      * @return WkHtmlToPdf
 18:      */
 19:     public function setFooterCenterText($text)
 20:     {
 21:         $this->arguments['footer-center'] = $text;
 22: 
 23:         return $this;
 24:     }
 25: 
 26:     /**
 27:      * Set footer font name (default Arial).
 28:      *
 29:      * @param string $name
 30:      *
 31:      * @return WkHtmlToPdf
 32:      */
 33:     public function setFooterFontName($name = 'Arial')
 34:     {
 35:         $this->arguments['footer-font-name'] = $name;
 36: 
 37:         return $this;
 38:     }
 39: 
 40:     /**
 41:      * Set footer font size (default 12).
 42:      *
 43:      * @param int $size
 44:      *
 45:      * @return WkHtmlToPdf
 46:      */
 47:     public function setFooterFontSize($size = 12)
 48:     {
 49:         $this->arguments['footer-font-size'] = intval($size);
 50: 
 51:         return $this;
 52:     }
 53: 
 54:     /**
 55:      * Adds a html footer.
 56:      *
 57:      * @param string $html
 58:      *
 59:      * @return WkHtmlToPdf
 60:      */
 61:     public function setFooterHtml($html)
 62:     {
 63:         $tmpFile = join_path($this->tmpDir, md5(time()) . '.html');
 64:         file_put_contents($tmpFile, $html);
 65: 
 66:         $this->arguments['footer-html'] = $tmpFile;
 67: 
 68:         return $this;
 69:     }
 70: 
 71:     /**
 72:      * Adds a html footer.
 73:      *
 74:      * @param string $path
 75:      *
 76:      * @return WkHtmlToPdf
 77:      */
 78:     public function setFooterHtmlPath($path)
 79:     {
 80:         $this->arguments['footer-html'] = $path;
 81: 
 82:         return $this;
 83:     }
 84: 
 85:     /**
 86:      * Left aligned footer text.
 87:      *
 88:      * @param string $text
 89:      *
 90:      * @return WkHtmlToPdf
 91:      */
 92:     public function setFooterLeftText($text)
 93:     {
 94:         $this->arguments['footer-left'] = $text;
 95: 
 96:         return $this;
 97:     }
 98: 
 99:     /**
100:      * Display line above the footer.
101:      *
102:      * @return WkHtmlToPdf
103:      */
104:     public function enableFooterLine()
105:     {
106:         if (array_key_exists('no-footer-line', $this->arguments)) {
107:             unset($this->arguments['no-footer-line']);
108:         }
109:         $this->arguments['footer-line'] = null;
110: 
111:         return $this;
112:     }
113: 
114:     /**
115:      * Do not display line above the footer.
116:      *
117:      * @return WkHtmlToPdf
118:      */
119:     public function disableFooterLine()
120:     {
121:         if (array_key_exists('footer-line', $this->arguments)) {
122:             unset($this->arguments['footer-line']);
123:         }
124:         $this->arguments['no-footer-line'] = null;
125: 
126:         return $this;
127:     }
128: 
129:     /**
130:      * Right aligned footer text.
131:      *
132:      * @param string $text
133:      *
134:      * @return WkHtmlToPdf
135:      */
136:     public function setFooterRightText($text)
137:     {
138:         $this->arguments['footer-right'] = $text;
139: 
140:         return $this;
141:     }
142: 
143:     /**
144:      * Spacing between footer and content in mm (default 0).
145:      *
146:      * @param float $spacing
147:      *
148:      * @return WkHtmlToPdf
149:      */
150:     public function setFooterSpacing($spacing = 0)
151:     {
152:         $this->arguments['footer-spacing'] = $spacing;
153: 
154:         return $this;
155:     }
156: 
157:     /**
158:      * Centered header text.
159:      *
160:      * @param string $text
161:      *
162:      * @return WkHtmlToPdf
163:      */
164:     public function setHeaderCenterText($text)
165:     {
166:         $this->arguments['header-center'] = $text;
167: 
168:         return $this;
169:     }
170: 
171:     /**
172:      * Set header font name (default Arial).
173:      *
174:      * @param string $name
175:      *
176:      * @return WkHtmlToPdf
177:      */
178:     public function setHeaderFontName($name = 'Arial')
179:     {
180:         $this->arguments['header-font-name'] = $name;
181: 
182:         return $this;
183:     }
184: 
185:     /**
186:      * Set header font size (default 12).
187:      *
188:      * @param int $size
189:      *
190:      * @return WkHtmlToPdf
191:      */
192:     public function setHeaderFontSize($size = 12)
193:     {
194:         $this->arguments['header-font-size'] = intval($size);
195: 
196:         return $this;
197:     }
198: 
199:     /**
200:      * Adds a html header.
201:      *
202:      * @param string $html
203:      *
204:      * @return WkHtmlToPdf
205:      */
206:     public function setHeaderHtml($html)
207:     {
208:         $tmpFile = join_path($this->tmpDir, md5(time()) . '.html');
209:         file_put_contents($tmpFile, $html);
210: 
211:         $this->arguments['header-html'] = $tmpFile;
212: 
213:         return $this;
214:     }
215: 
216:     /**
217:      * Adds a html header.
218:      *
219:      * @param string $path
220:      *
221:      * @return WkHtmlToPdf
222:      */
223:     public function setHeaderHtmlPath($path)
224:     {
225:         $this->arguments['header-html'] = $path;
226: 
227:         return $this;
228:     }
229: 
230:     /**
231:      * Left aligned header text.
232:      *
233:      * @param string $text
234:      *
235:      * @return WkHtmlToPdf
236:      */
237:     public function setHeaderLeftText($text)
238:     {
239:         $this->arguments['header-left'] = $text;
240: 
241:         return $this;
242:     }
243: 
244:     /**
245:      * Display line above the header.
246:      *
247:      * @return WkHtmlToPdf
248:      */
249:     public function enableHeaderLine()
250:     {
251:         if (array_key_exists('no-header-line', $this->arguments)) {
252:             unset($this->arguments['no-header-line']);
253:         }
254:         $this->arguments['header-line'] = null;
255: 
256:         return $this;
257:     }
258: 
259:     /**
260:      * Do not display line above the header.
261:      *
262:      * @return WkHtmlToPdf
263:      */
264:     public function disableHeaderLine()
265:     {
266:         if (array_key_exists('header-line', $this->arguments)) {
267:             unset($this->arguments['header-line']);
268:         }
269:         $this->arguments['no-header-line'] = null;
270: 
271:         return $this;
272:     }
273: 
274:     /**
275:      * Right aligned header text.
276:      *
277:      * @param string $text
278:      *
279:      * @return WkHtmlToPdf
280:      */
281:     public function setHeaderRightText($text)
282:     {
283:         $this->arguments['header-right'] = $text;
284: 
285:         return $this;
286:     }
287: 
288:     /**
289:      * Spacing between header and content in mm (default 0).
290:      *
291:      * @param float $spacing
292:      *
293:      * @return WkHtmlToPdf
294:      */
295:     public function setHeaderSpacing($spacing = 0)
296:     {
297:         $this->arguments['header-spacing'] = $spacing;
298: 
299:         return $this;
300:     }
301: 
302:     /**
303:      * Add custom value to be replaced in header/footer (--replace argument).
304:      *
305:      * @param string $name
306:      * @param string $value
307:      *
308:      * @return WkHtmlToPdf
309:      */
310:     public function addHeaderFooterVar($name, $value)
311:     {
312:         $this->arguments['replace'][$name] = $value;
313: 
314:         return $this;
315:     }
316: 
317:     /**
318:      * Add custom values to be replaced in header/footer (--replace argument).
319:      *
320:      * @param array $vars
321:      *
322:      * @return WkHtmlToPdf
323:      */
324:     public function addHeaderFooterVars(array $vars)
325:     {
326:         foreach ($vars as $name => $value) {
327:             $this->arguments['replace'][$name] = $value;
328:         }
329: 
330:         return $this;
331:     }
332: }
333: 
wkp2p API documentation generated by ApiGen