@@ -21,7 +21,7 @@ class PDF
2121 'bottom ' => 0 ,
2222 'left ' => 0 ,
2323 ),
24- 'printBackground ' => ' true ' , //override binary default
24+ 'printBackground ' => true , //override binary default
2525 );
2626
2727 /**
@@ -87,14 +87,14 @@ public function __construct(string $pathtobinary = 'chrome-pdf')
8787 *
8888 * @param array $options a reference to an existing array of options
8989 * @param string $name the name of the option to apply
90- * @param string $value the input value
90+ * @param string|bool $value the input value
9191 *
9292 * @throws InvalidOptionException
9393 * @throws InvalidValueException
9494 *
9595 * @return void
9696 */
97- protected function addOption (array &$ options , string $ name , string $ value ) : void
97+ protected function addOption (array &$ options , string $ name , $ value ) : void
9898 {
9999 if (in_array ($ name , $ this ->possibleoptions )) {
100100 if ($ name == 'margin ' ) {
@@ -160,11 +160,11 @@ protected function addOption(array &$options, string $name, string $value) : voi
160160 * Public interface to addOption function
161161 *
162162 * @param string $name the name of the option to apply
163- * @param string $value the input value
163+ * @param string|bool $value the input value
164164 *
165165 * @return self allows chaining
166166 */
167- public function setOption (string $ name , string $ value ) : self
167+ public function setOption (string $ name , $ value ) : self
168168 {
169169 $ this ->addOption ($ this ->options , $ name , $ value );
170170
@@ -337,7 +337,7 @@ private function make(array $options) : string
337337 foreach ($ options as $ option => $ value ) {
338338 if ($ option == 'sandbox ' ) {
339339 // only mess with sandbox if it is explicitly disabled
340- if ($ value == ' false ' ) {
340+ if ($ value === false ) {
341341 $ command [] = '--no-sandbox ' ;
342342 }
343343
@@ -357,7 +357,18 @@ private function make(array $options) : string
357357 }
358358
359359 $ command [] = '-- ' . $ option ;
360- $ command [] = (is_array ($ value )) ? implode (', ' , $ value ) : $ value ;
360+
361+ if (is_array ($ value )) {
362+ $ command [] = implode (', ' , $ value );
363+ continue ;
364+ } elseif ($ value === true || $ value === false ) {
365+ $ command [] = var_export ($ value , true );
366+ continue ;
367+ } elseif (! is_string ($ value )) {
368+ throw new InvalidValueException ;
369+ }
370+
371+ $ command [] = $ value ;
361372 }
362373
363374 $ process = new Process ($ command );
0 commit comments