mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 15:54:03 +02:00
Pdf: Ensure dompdf can create temporary files
This is required since dompdf seems to automatically load our custom font and complains otherwise. (cherry picked from commit 191444ccd9bb3ea8ef1a2502a8c981e3b66a98cd)
This commit is contained in:
parent
acb8c80d64
commit
4a479e48db
@ -5,9 +5,11 @@ namespace Icinga\File;
|
|||||||
|
|
||||||
use Dompdf\Dompdf;
|
use Dompdf\Dompdf;
|
||||||
use Dompdf\Options;
|
use Dompdf\Options;
|
||||||
|
use Exception;
|
||||||
use Icinga\Application\Icinga;
|
use Icinga\Application\Icinga;
|
||||||
use Icinga\Exception\ProgrammingError;
|
use Icinga\Exception\ProgrammingError;
|
||||||
use Icinga\Util\Environment;
|
use Icinga\Util\Environment;
|
||||||
|
use Icinga\Web\FileCache;
|
||||||
use Icinga\Web\Hook;
|
use Icinga\Web\Hook;
|
||||||
use Icinga\Web\Url;
|
use Icinga\Web\Url;
|
||||||
|
|
||||||
@ -79,8 +81,17 @@ class Pdf
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$tmpDir = FileCache::instance()->directory('legacy_pdf');
|
||||||
|
if ($tmpDir === false) {
|
||||||
|
throw new Exception('Could not create temporary directory for PDF rendering');
|
||||||
|
}
|
||||||
|
|
||||||
$options = new Options();
|
$options = new Options();
|
||||||
$options->set('defaultPaperSize', 'A4');
|
$options->set('defaultPaperSize', 'A4');
|
||||||
|
$options->set('fontDir', $tmpDir);
|
||||||
|
$options->set('fontCache', $tmpDir);
|
||||||
|
$options->set('tempDir', $tmpDir);
|
||||||
|
$options->set('chroot', $tmpDir);
|
||||||
$dompdf = new Dompdf($options);
|
$dompdf = new Dompdf($options);
|
||||||
$dompdf->loadHtml($html);
|
$dompdf->loadHtml($html);
|
||||||
$dompdf->render();
|
$dompdf->render();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user