diff --git a/library/Icinga/File/Pdf.php b/library/Icinga/File/Pdf.php index dfe8f74d3..fd68596fe 100644 --- a/library/Icinga/File/Pdf.php +++ b/library/Icinga/File/Pdf.php @@ -51,14 +51,19 @@ class Pdf Environment::raiseExecutionTime(300); $viewRenderer = $controller->getHelper('viewRenderer'); - $controller->render( - $viewRenderer->getScriptAction(), - $viewRenderer->getResponseSegment(), - $viewRenderer->getNoController() - ); - $layout = $controller->getHelper('layout')->setLayout('pdf'); + $viewRenderer->postDispatch(); + + $layoutHelper = $controller->getHelper('layout'); + $oldLayout = $layoutHelper->getLayout(); + $layout = $layoutHelper->setLayout('pdf'); + $layout->content = $controller->getResponse(); $html = $layout->render(); + + // Restore previous layout and reset content, to properly show errors + $controller->getResponse()->clearBody($viewRenderer->getResponseSegment()); + $layoutHelper->setLayout($oldLayout); + $imgDir = Url::fromPath('img'); $html = preg_replace( '~src="' . $imgDir . '/~', diff --git a/library/Icinga/Web/Controller/ActionController.php b/library/Icinga/Web/Controller/ActionController.php index 7a8aa0e7e..d4fcb7a8d 100644 --- a/library/Icinga/Web/Controller/ActionController.php +++ b/library/Icinga/Web/Controller/ActionController.php @@ -483,9 +483,9 @@ class ActionController extends Zend_Controller_Action } } - if ($req->getParam('format') === 'pdf') { - $this->shutdownSession(); + if ($req->getParam('error_handler') === null && $req->getParam('format') === 'pdf') { $this->sendAsPdf(); + $this->shutdownSession(); exit; }