-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
39 lines (35 loc) · 911 Bytes
/
index.php
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
38
39
<?php
@include_once __DIR__ . '/vendor/autoload.php';
use Kirby\Cms\App;
use Kirby\Cms\Response;
use Maxchene\KirbyPdf\KirbyPdf;
App::plugin('maxchene/kirby-pdf', [
'options' => [
'engine' => 'WkHtmlToPdf',
'margin' => [
'bottom' => 10,
'left' => 10,
'right' => 10,
'top' => 10,
],
'orientation' => 'portrait'
],
'routes' => [
[
'pattern' => '(:all).pdf',
'action' => function (string $all) {
$page = page($all);
$pdf = new KirbyPdf();
$output = $pdf
->setPage($page)
->output();
return new Response($output, 'application/pdf');
}
]
],
'pageMethods' => [
'pdfUrl' => function () {
return $this->url() . '.pdf';
}
]
]);