1: <?php
2:
3: namespace WkHtmlToPdf\Options;
4:
5: use WkHtmlToPdf\WkHtmlToPdf;
6:
7: 8: 9: 10: 11:
12: trait GlobalOptionsTrait
13: {
14: 15: 16: 17: 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: 31: 32: 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: 46: 47: 48: 49: 50:
51: public function setCookieJar($path)
52: {
53: $this->arguments['cookie-jar'] = $path;
54:
55: return $this;
56: }
57:
58: 59: 60: 61: 62: 63: 64:
65: public function setCopies($number = 1)
66: {
67: $this->arguments['copies'] = $number;
68:
69: return $this;
70: }
71:
72: 73: 74: 75: 76: 77: 78:
79: public function setDpi($dpi)
80: {
81: $this->arguments['dpi'] = $dpi;
82:
83: return $this;
84: }
85:
86: 87: 88: 89: 90:
91: public function enableGrayscale()
92: {
93: if (!array_key_exists('grayscale', $this->arguments)) {
94: $this->arguments['grayscale'] = null;
95: }
96: }
97:
98: 99: 100: 101: 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: 114: 115: 116: 117: 118:
119: public function setImageDpi($imageDpi = 600)
120: {
121: $this->arguments['image-dpi'] = $imageDpi;
122:
123: return $this;
124: }
125:
126: 127: 128: 129: 130: 131: 132:
133: public function setImageQuality($imageQuality = 94)
134: {
135: $this->arguments['image-quality'] = $imageQuality;
136:
137: return $this;
138: }
139:
140: 141: 142: 143: 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: 156: 157: 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: 170: 171: 172: 173: 174:
175: public function setMarginBottom($marginBottom)
176: {
177: $this->arguments['margin-bottom'] = $marginBottom;
178:
179: return $this;
180: }
181:
182: 183: 184: 185: 186: 187: 188:
189: public function setMarginLeft($marginLeft)
190: {
191: $this->arguments['margin-left'] = $marginLeft;
192:
193: return $this;
194: }
195:
196: 197: 198: 199: 200: 201: 202:
203: public function setMarginRight($marginRight)
204: {
205: $this->arguments['margin-right'] = $marginRight;
206:
207: return $this;
208: }
209:
210: 211: 212: 213: 214: 215: 216:
217: public function setMarginTop($marginTop)
218: {
219: $this->arguments['margin-top'] = $marginTop;
220:
221: return $this;
222: }
223:
224: 225: 226: 227: 228: 229: 230: 231: 232: 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: 246: 247: 248: 249: 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: 263: 264: 265: 266: 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: 285: 286: 287: 288: 289:
290: public function setPageHeight($pageHeight)
291: {
292: $this->arguments['page-height'] = $pageHeight;
293:
294: return $this;
295: }
296:
297: 298: 299: 300: 301: 302: 303:
304: public function setPageWidth($pageWidth)
305: {
306: $this->arguments['page-width'] = $pageWidth;
307:
308: return $this;
309: }
310:
311: 312: 313: 314: 315: 316: 317:
318: public function setPageSize($pageSize = 'A4')
319: {
320: $this->arguments['page-size'] = $pageSize;
321:
322: return $this;
323: }
324:
325: 326: 327: 328: 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: 341: 342: 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: 355: 356: 357: 358: 359:
360: public function setTitle($title)
361: {
362: $this->arguments['title'] = $title;
363:
364: return $this;
365: }
366:
367: 368: 369: 370: 371: 372: 373:
374: public function setDocumentTitle($title)
375: {
376: $this->arguments['title'] = $title;
377:
378: return $this;
379: }
380:
381: 382: 383: 384: 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: 397: 398: 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: