1 | <?php |
||
20 | class PdfWrite extends AbstractDevice |
||
21 | { |
||
22 | /** |
||
23 | * Use distiller options |
||
24 | */ |
||
25 | use DistillerParametersTrait; |
||
26 | |||
27 | /** |
||
28 | * Use color image compression distiller options |
||
29 | */ |
||
30 | use DistillerParameters\ColorImageCompressionTrait; |
||
31 | |||
32 | /** |
||
33 | * Use grayscale image compression distiller options |
||
34 | */ |
||
35 | use DistillerParameters\GrayImageCompressionTrait; |
||
36 | |||
37 | /** |
||
38 | * Use monochrome image compression distiller options |
||
39 | */ |
||
40 | use DistillerParameters\MonoImageCompressionTrait; |
||
41 | |||
42 | /** |
||
43 | * Use page compression distiller options |
||
44 | */ |
||
45 | use DistillerParameters\PageCompressionTrait; |
||
46 | |||
47 | /** |
||
48 | * Use font distiller options |
||
49 | */ |
||
50 | use DistillerParameters\FontTrait; |
||
51 | |||
52 | /** |
||
53 | * Use color conversion distiller options |
||
54 | */ |
||
55 | use DistillerParameters\ColorConversionTrait; |
||
56 | |||
57 | /** |
||
58 | * Use advanced distiller options |
||
59 | */ |
||
60 | use DistillerParameters\AdvancedTrait; |
||
61 | |||
62 | /** |
||
63 | * This operator conditions the environment for the pdfwrite output device. It is a shorthand for setting parameters |
||
64 | * that have been deemed benificial. While not strictly necessary, it is usually helpful to set call this when using |
||
65 | * the pdfwrite device. |
||
66 | * |
||
67 | * @link http://ghostscript.com/doc/current/Language.htm#.setpdfwrite |
||
68 | */ |
||
69 | const POSTSCRIPT_COMMANDS = '.setpdfwrite'; |
||
70 | |||
71 | /** |
||
72 | * Create PDF write device object |
||
73 | * |
||
74 | * @param Ghostscript $ghostscript |
||
75 | * @param Arguments $arguments |
||
76 | */ |
||
77 | 26 | public function __construct(Ghostscript $ghostscript, Arguments $arguments) |
|
78 | { |
||
79 | 26 | parent::__construct($ghostscript, $arguments->setArgument('-sDEVICE=pdfwrite')); |
|
80 | |||
81 | 26 | $this->setPdfSettings(PdfSettings::__DEFAULT); |
|
82 | 26 | } |
|
83 | |||
84 | /** |
||
85 | * Get output file |
||
86 | * |
||
87 | * @return null|string |
||
88 | */ |
||
89 | 4 | public function getOutputFile() |
|
90 | { |
||
91 | 4 | return $this->getArgumentValue('-sOutputFile'); |
|
92 | } |
||
93 | |||
94 | /** |
||
95 | * Set output file |
||
96 | * |
||
97 | * @param string $outputFile |
||
98 | * |
||
99 | * @return $this |
||
100 | */ |
||
101 | 4 | public function setOutputFile($outputFile) |
|
102 | { |
||
103 | 4 | $this->setArgument('-sOutputFile=' . $outputFile); |
|
104 | |||
105 | 4 | return $this; |
|
106 | } |
||
107 | |||
108 | /** |
||
109 | * Whether output file is stdout. |
||
110 | * |
||
111 | * @return bool |
||
112 | */ |
||
113 | 2 | public function isOutputStdout() |
|
114 | { |
||
115 | 2 | return $this->getOutputFile() == '-'; |
|
116 | } |
||
117 | |||
118 | /** |
||
119 | * Set stdout as output. |
||
120 | * |
||
121 | * @return $this |
||
122 | */ |
||
123 | 2 | public function setOutputStdout() |
|
127 | |||
128 | /** |
||
129 | * Get PDF settings |
||
130 | * |
||
131 | * @return string |
||
132 | */ |
||
133 | 10 | public function getPdfSettings() |
|
137 | |||
138 | /** |
||
139 | * Set PDF settings |
||
140 | * |
||
141 | * @param string $pdfSettings |
||
142 | * |
||
143 | * @throws \InvalidArgumentException |
||
144 | * |
||
145 | * @return $this |
||
146 | */ |
||
147 | 26 | public function setPdfSettings($pdfSettings) |
|
158 | |||
159 | /** |
||
160 | * Get process color model |
||
161 | * |
||
162 | * @return string |
||
163 | */ |
||
164 | 6 | public function getProcessColorModel() |
|
168 | |||
169 | /** |
||
170 | * Set process color model |
||
171 | * |
||
172 | * @param string $processColorModel |
||
173 | * |
||
174 | * @throws \InvalidArgumentException |
||
175 | * |
||
176 | * @return $this |
||
177 | */ |
||
178 | 8 | public function setProcessColorModel($processColorModel) |
|
189 | } |
||
190 |