Skip to content

Commit bc4f060

Browse files
yhabteabsukhwinder33445
authored andcommitted
Pdfexport: Generate PDF before modifying response headers
1 parent 4e201da commit bc4f060

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

library/Pdfexport/ProvidedHook/Pdfexport.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,15 @@ public function streamPdfFromHtml($html, $filename)
132132
{
133133
$filename = basename($filename, '.pdf') . '.pdf';
134134

135+
// Generate the PDF before changing the response headers to properly handle and display errors in the UI.
136+
$pdf = $this->htmlToPdf($html);
137+
135138
/** @var Web $app */
136139
$app = Icinga::app();
137140
$app->getResponse()
138141
->setHeader('Content-Type', 'application/pdf', true)
139142
->setHeader('Content-Disposition', "inline; filename=\"$filename\"", true)
140-
->setBody($this->htmlToPdf($html))
143+
->setBody($pdf)
141144
->sendResponse();
142145

143146
exit;

0 commit comments

Comments
 (0)