diff --git a/library/Icinga/Application/Hook/PdfexportHook.php b/library/Icinga/Application/Hook/PdfexportHook.php new file mode 100644 index 000000000..36e9f515c --- /dev/null +++ b/library/Icinga/Application/Hook/PdfexportHook.php @@ -0,0 +1,25 @@ +getBootstrapDirectory() . '/img/', $html ); + + $request = $controller->getRequest(); + + if (Hook::has('Pdfexport')) { + $pdfexport = Hook::first('Pdfexport'); + + if ($pdfexport->isSupported()) { + $pdfexport->streamPdfFromHtml($html, sprintf( + '%s-%s-%d', + $request->getControllerName(), + $request->getActionName(), + time() + )); + + return; + } + } + $options = new Options(); $options->set('defaultPaperSize', 'A4'); $dompdf = new Dompdf($options); $dompdf->loadHtml($html); $dompdf->render(); - $request = $controller->getRequest(); $dompdf->stream( sprintf( '%s-%s-%d', diff --git a/library/Icinga/Web/Widget/Tabextension/OutputFormat.php b/library/Icinga/Web/Widget/Tabextension/OutputFormat.php index dbf844e69..ea33485e9 100644 --- a/library/Icinga/Web/Widget/Tabextension/OutputFormat.php +++ b/library/Icinga/Web/Widget/Tabextension/OutputFormat.php @@ -4,6 +4,7 @@ namespace Icinga\Web\Widget\Tabextension; use Icinga\Application\Platform; +use Icinga\Application\Hook; use Icinga\Web\Url; use Icinga\Web\Widget\Tab; use Icinga\Web\Widget\Tabs; @@ -81,7 +82,13 @@ class OutputFormat implements Tabextension { $supportedTypes = array(); - if (Platform::extensionLoaded('gd')) { + $pdfexport = false; + + if (Hook::has('Pdfexport')) { + $pdfexport = Hook::first('Pdfexport')->isSupported(); + } + + if ($pdfexport || Platform::extensionLoaded('gd')) { $supportedTypes[self::TYPE_PDF] = array( 'name' => 'pdf', 'label' => 'PDF',