Skip to content

Commit 59a3c16

Browse files
committed
use temporary files to handle header and footer content
1 parent 98cfa18 commit 59a3c16

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/PDF.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ class PDF
3737
'landscape',
3838
'scale',
3939
'displayHeaderFooter',
40+
'headerContent',
41+
'footerContent',
4042
'headerTemplate',
4143
'footerTemplate',
4244
'printBackground',
@@ -332,6 +334,17 @@ private function make(array $options) : string
332334
}
333335

334336
foreach ($options as $option => $value) {
337+
if ($option == 'headerContent' || $option == 'footerContent') {
338+
$tmpfile = tmpfile();
339+
fwrite($tmpfile, $value);
340+
341+
$option = str_replace('Content', 'Template', $option);
342+
343+
$command[] = '--' . $option;
344+
$command[] = stream_get_meta_data($tmpfile)['uri'];
345+
continue;
346+
}
347+
335348
$command[] = '--' . $option;
336349
$command[] = (is_array($value)) ? implode(',', $value) : $value;
337350
}

0 commit comments

Comments
 (0)