2019-10-17 17:55:32 +02:00
|
|
|
<?php
|
|
|
|
require '_vendor/autoload.php';
|
|
|
|
|
|
|
|
require '_templates/Template.php';
|
|
|
|
require '_util/PileDB.php';
|
|
|
|
|
|
|
|
|
|
|
|
$db = new PileDB();
|
2019-10-18 14:08:54 +02:00
|
|
|
try {
|
|
|
|
$doc = $db->fetchDoc($_GET["id"]);
|
2019-11-02 14:56:05 +01:00
|
|
|
} catch (NotFoundException $e) {
|
2019-10-18 14:08:54 +02:00
|
|
|
http_response_code(404);
|
|
|
|
$page->text = "Document not found.";
|
|
|
|
$page->redirect = "/";
|
|
|
|
echo $page->render("full_text.php");
|
|
|
|
die(0);
|
|
|
|
}
|
2019-10-17 17:55:32 +02:00
|
|
|
|
|
|
|
$front = new Template();
|
|
|
|
$front->doc = $doc;
|
|
|
|
|
|
|
|
$defaultConfig = (new \Mpdf\Config\ConfigVariables())->getDefaults();
|
|
|
|
$fontDirs = $defaultConfig['fontDir'];
|
|
|
|
$defaultFontConfig = (new \Mpdf\Config\FontVariables())->getDefaults();
|
|
|
|
$fontData = $defaultFontConfig['fontdata'];
|
|
|
|
try {
|
|
|
|
$mpdf = new \Mpdf\Mpdf([
|
|
|
|
'format' => 'A4',
|
|
|
|
'fontDir' => array_merge($fontDirs, [
|
|
|
|
__DIR__ . '/assets',
|
|
|
|
]),
|
|
|
|
'fontdata' => $fontData + [
|
|
|
|
'prociono' => [
|
|
|
|
'R' => 'Prociono-Regular.ttf',
|
|
|
|
]
|
|
|
|
],
|
|
|
|
'default_font' => 'prociono'
|
|
|
|
]);
|
|
|
|
|
|
|
|
$mpdf->showImageErrors = true;
|
|
|
|
$mpdf->WriteHTML($front->render("_templates/label_template.php"));
|
|
|
|
$mpdf->Output();
|
2019-10-18 14:08:54 +02:00
|
|
|
} catch (Exception $exception) {
|
2019-10-17 17:55:32 +02:00
|
|
|
http_response_code(500); ?>
|
|
|
|
<h1>Something went wrong generating the label.</h1>
|
|
|
|
<pre><?= $exception->getMessage() ?></pre>
|
2019-10-17 18:13:11 +02:00
|
|
|
<?php } ?>
|