-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
37 lines (28 loc) · 820 Bytes
/
index.php
File metadata and controls
37 lines (28 loc) · 820 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
declare(strict_types=1);
require __DIR__ . '/vendor/autoload.php';
use Knp\Snappy\Pdf;
return function (array $event) {
$pdf = new Pdf('/opt/bin/wkhtmltopdf');
$options = [
'encoding' => 'utf-8',
'page-size' => 'A4',
'margin-bottom' => 0,
'margin-left' => 0,
'margin-top' => 0,
'margin-right' => 0,
'disable-smart-shrinking' => true,
'disable-javascript' => true,
];
if (isset($event['options'])) {
$options = \array_merge(
$options,
\json_decode($event['options'], true)
);
}
$output = $pdf->getOutputFromHtml($event['html'], $options);
if (empty($output)) {
throw new \RuntimeException('Unable to generate the html');
}
return \base64_encode($output);
};