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:  * General wkhtmltopdf options.
  9:  *
 10:  * @author ivanpepelko
 11:  */
 12: trait GlobalOptionsTrait
 13: {
 14:     /**
 15:      * Collate when printing multiple copies (default true).
 16:      *
 17:      * @return WkHtmlToPdf
 18:      */
 19:     public function enableCollate()
 20:     {
 21:         if (array_key_exists('no-collate', $this->arguments)) {
 22:             unset($this->arguments['no-collate']);
 23:         }
 24:         $this->arguments['collate'] = null;
 25: 
 26:         return $this;
 27:     }
 28: 
 29:     /**
 30:      * Do not collate when printing multiple copies (default true).
 31:      *
 32:      * @return WkHtmlToPdf
 33:      */
 34:     public function disableCollate()
 35:     {
 36:         if (array_key_exists('collate', $this->arguments)) {
 37:             unset($this->arguments['collate']);
 38:         }
 39:         $this->arguments['no-collate'] = null;
 40: 
 41:         return $this;
 42:     }
 43: 
 44:     /**
 45:      * Read and write cookies from and to the supplied cookie jar file.
 46:      *
 47:      * @param string $path
 48:      *
 49:      * @return WkHtmlToPdf
 50:      */
 51:     public function setCookieJar($path)
 52:     {
 53:         $this->arguments['cookie-jar'] = $path;
 54: 
 55:         return $this;
 56:     }
 57: 
 58:     /**
 59:      * Number of copies to print into the pdf file (default 1).
 60:      *
 61:      * @param int $number
 62:      *
 63:      * @return WkHtmlToPdf
 64:      */
 65:     public function setCopies($number = 1)
 66:     {
 67:         $this->arguments['copies'] = $number;
 68: 
 69:         return $this;
 70:     }
 71: 
 72:     /**
 73:      * Change the dpi explicitly (this has no effect on X11 based systems).
 74:      *
 75:      * @param int $dpi
 76:      *
 77:      * @return WkHtmlToPdf
 78:      */
 79:     public function setDpi($dpi)
 80:     {
 81:         $this->arguments['dpi'] = $dpi;
 82: 
 83:         return $this;
 84:     }
 85: 
 86:     /**
 87:      * PDF will be generated in grayscale.
 88:      *
 89:      * @return WkHtmlToPdf
 90:      */
 91:     public function enableGrayscale()
 92:     {
 93:         if (!array_key_exists('grayscale', $this->arguments)) {
 94:             $this->arguments['grayscale'] = null;
 95:         }
 96:     }
 97: 
 98:     /**
 99:      * PDF will not be generated in grayscale.
100:      *
101:      * @return WkHtmlToPdf
102:      */
103:     public function disableGrayscale()
104:     {
105:         if (array_key_exists('grayscale', $this->arguments)) {
106:             unset($this->arguments['grayscale']);
107:         }
108: 
109:         return $this;
110:     }
111: 
112:     /**
113:      * When embedding images scale them down to this dpi (default 600).
114:      *
115:      * @param int $imageDpi
116:      *
117:      * @return WkHtmlToPdf
118:      */
119:     public function setImageDpi($imageDpi = 600)
120:     {
121:         $this->arguments['image-dpi'] = $imageDpi;
122: 
123:         return $this;
124:     }
125: 
126:     /**
127:      * When jpeg compressing images use this quality (default 94).
128:      *
129:      * @param int $imageQuality
130:      *
131:      * @return WkHtmlToPdf
132:      */
133:     public function setImageQuality($imageQuality = 94)
134:     {
135:         $this->arguments['image-quality'] = $imageQuality;
136: 
137:         return $this;
138:     }
139: 
140:     /**
141:      * Generates lower quality pdf/ps. Useful to shrink the result document space.
142:      *
143:      * @return WkHtmlToPdf
144:      */
145:     public function enableLowQuality()
146:     {
147:         if (!array_key_exists('lowquality', $this->arguments)) {
148:             $this->arguments['lowquality'] = null;
149:         }
150: 
151:         return $this;
152:     }
153: 
154:     /**
155:      * Disable lower quality pdf/ps.
156:      *
157:      * @return WkHtmlToPdf
158:      */
159:     public function disableLowQuality()
160:     {
161:         if (array_key_exists('lowquality', $this->arguments)) {
162:             unset($this->arguments['lowquality']);
163:         }
164: 
165:         return $this;
166:     }
167: 
168:     /**
169:      * Set the page bottom margin.
170:      *
171:      * @param string $marginBottom
172:      *
173:      * @return WkHtmlToPdf
174:      */
175:     public function setMarginBottom($marginBottom)
176:     {
177:         $this->arguments['margin-bottom'] = $marginBottom;
178: 
179:         return $this;
180:     }
181: 
182:     /**
183:      * Set the page left margin (default 10mm).
184:      *
185:      * @param string $marginLeft
186:      *
187:      * @return WkHtmlToPdf
188:      */
189:     public function setMarginLeft($marginLeft)
190:     {
191:         $this->arguments['margin-left'] = $marginLeft;
192: 
193:         return $this;
194:     }
195: 
196:     /**
197:      * Set the page right margin (default 10mm).
198:      *
199:      * @param string $marginRight
200:      *
201:      * @return WkHtmlToPdf
202:      */
203:     public function setMarginRight($marginRight)
204:     {
205:         $this->arguments['margin-right'] = $marginRight;
206: 
207:         return $this;
208:     }
209: 
210:     /**
211:      * Set the page top margin.
212:      *
213:      * @param string $marginTop
214:      *
215:      * @return WkHtmlToPdf
216:      */
217:     public function setMarginTop($marginTop)
218:     {
219:         $this->arguments['margin-top'] = $marginTop;
220: 
221:         return $this;
222:     }
223: 
224:     /**
225:      * Set all margins.
226:      *
227:      * @param string $marginTop
228:      * @param string $marginRight
229:      * @param string $marginBottom
230:      * @param string $marginLeft
231:      *
232:      * @return WkHtmlToPdf
233:      */
234:     public function setMargins($marginTop, $marginRight, $marginBottom, $marginLeft)
235:     {
236:         $this->arguments['margin-top'] = $marginTop;
237:         $this->arguments['margin-right'] = $marginRight;
238:         $this->arguments['margin-bottom'] = $marginBottom;
239:         $this->arguments['margin-left'] = $marginLeft;
240: 
241:         return $this;
242:     }
243: 
244:     /**
245:      * Set all margins to same size.
246:      *
247:      * @param type $margin
248:      *
249:      * @return WkHtmlToPdf
250:      */
251:     public function setMarginsAll($margin)
252:     {
253:         $this->arguments['margin-top'] = $margin;
254:         $this->arguments['margin-right'] = $margin;
255:         $this->arguments['margin-bottom'] = $margin;
256:         $this->arguments['margin-left'] = $margin;
257: 
258:         return $this;
259:     }
260: 
261:     /**
262:      * Set orientation to Landscape or Portrait (or P|L, default Portrait).
263:      *
264:      * @param string $orientation
265:      *
266:      * @return WkHtmlToPdf
267:      */
268:     public function setOrientation($orientation = 'Portrait')
269:     {
270:         if ('P' === $orientation) {
271:             $orientation = 'Portrait';
272:         }
273: 
274:         if ('L' === $orientation) {
275:             $orientation = 'Landscape';
276:         }
277: 
278:         $this->arguments['orientation'] = ucfirst($orientation);
279: 
280:         return $this;
281:     }
282: 
283:     /**
284:      * Set page height.
285:      *
286:      * @param string $pageHeight
287:      *
288:      * @return WkHtmlToPdf
289:      */
290:     public function setPageHeight($pageHeight)
291:     {
292:         $this->arguments['page-height'] = $pageHeight;
293: 
294:         return $this;
295:     }
296: 
297:     /**
298:      * Set page width.
299:      *
300:      * @param string $pageWidth
301:      *
302:      * @return WkHtmlToPdf
303:      */
304:     public function setPageWidth($pageWidth)
305:     {
306:         $this->arguments['page-width'] = $pageWidth;
307: 
308:         return $this;
309:     }
310: 
311:     /**
312:      * Set paper size to: A4, Letter, etc. (default A4).
313:      *
314:      * @param string $pageSize
315:      *
316:      * @return WkHtmlToPdf
317:      */
318:     public function setPageSize($pageSize = 'A4')
319:     {
320:         $this->arguments['page-size'] = $pageSize;
321: 
322:         return $this;
323:     }
324: 
325:     /**
326:      * Use lossless compression on pdf objects.
327:      *
328:      * @return WkHtmlToPdf
329:      */
330:     public function enablePdfCompression()
331:     {
332:         if (array_key_exists('no-pdf-compression', $this->arguments)) {
333:             unset($this->arguments['no-pdf-compression']);
334:         }
335: 
336:         return $this;
337:     }
338: 
339:     /**
340:      * Disable using of lossless compression on pdf objects.
341:      *
342:      * @return WkHtmlToPdf
343:      */
344:     public function disablePdfCompression()
345:     {
346:         if (!array_key_exists('no-pdf-compression', $this->arguments)) {
347:             $this->arguments['no-pdf-compression'] = null;
348:         }
349: 
350:         return $this;
351:     }
352: 
353:     /**
354:      * The title of the generated pdf file (The title of the first document is used if not specified).
355:      *
356:      * @param string $title
357:      *
358:      * @return WkHtmlToPdf
359:      */
360:     public function setTitle($title)
361:     {
362:         $this->arguments['title'] = $title;
363: 
364:         return $this;
365:     }
366: 
367:     /**
368:      * Alias of setTitle.
369:      *
370:      * @param string $title
371:      *
372:      * @return WkHtmlToPdf
373:      */
374:     public function setDocumentTitle($title)
375:     {
376:         $this->arguments['title'] = $title;
377: 
378:         return $this;
379:     }
380: 
381:     /**
382:      * Use the X server (some plugins and other stuff might not work without X11).
383:      *
384:      * @return WkHtmlToPdf
385:      */
386:     public function enableXserver()
387:     {
388:         if (!array_key_exists('use-xserver', $this->arguments)) {
389:             $this->arguments['use-xserver'] = null;
390:         }
391: 
392:         return $this;
393:     }
394: 
395:     /**
396:      * Do not use the X server (some plugins and other stuff might not work without X11).
397:      *
398:      * @return WkHtmlToPdf
399:      */
400:     public function disableXserver()
401:     {
402:         if (array_key_exists('use-xserver', $this->arguments)) {
403:             unset($this->arguments['use-xserver']);
404:         }
405: 
406:         return $this;
407:     }
408: }
409: 
wkp2p API documentation generated by ApiGen