Skip to content

Commit a121ea9

Browse files
committed
Merge remote-tracking branch 'origin/fixes/sandbox'
2 parents 98cfa18 + 5b20e06 commit a121ea9

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ Instantiate the class, passing the path to the `chrome-pdf` binary if necessary,
1818

1919
The available options can be seen in the code. There is also functionality to handle a CSS-style declaring of margins to make input easier.
2020

21+
### Docker Support
22+
23+
In order to run chrome-pdf inside a Docker container, you will have to disable the sandbox feature by setting the `sandbox` option to `"false"` (string not boolean).
24+
2125
## Examples
2226

2327
### Laravel Example

src/PDF.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class PDF
4747
'margin',
4848
'preferCSSPageSize',
4949
'file',
50+
'sandbox',
5051
);
5152

5253
/**
@@ -332,6 +333,16 @@ private function make(array $options) : string
332333
}
333334

334335
foreach ($options as $option => $value) {
336+
if ($option == 'sandbox') {
337+
// only mess with sandbox if it is explicitly disabled
338+
if ($value == 'false') {
339+
$command[] = '--no-sandbox';
340+
}
341+
342+
// don't need the below lines
343+
continue;
344+
}
345+
335346
$command[] = '--' . $option;
336347
$command[] = (is_array($value)) ? implode(',', $value) : $value;
337348
}

0 commit comments

Comments
 (0)