protected function buildPdf(Document\PrintAbstract $document, $config)
{
$web2printConfig = Config::getWeb2PrintConfig();
$params = [];
$this->updateStatus($document->getId(), 10, "start_html_rendering");
$html = $document->renderDocument($params);
$placeholder = new \Pimcore\Placeholder();
$html = $placeholder->replacePlaceholders($html);
$html = \Pimcore\Helper\Mail::setAbsolutePaths($html, $document, $web2printConfig->wkhtml2pdfHostname);
$this->updateStatus($document->getId(), 40, "finished_html_rendering");
file_put_contents(PIMCORE_TEMPORARY_DIRECTORY . DIRECTORY_SEPARATOR . "wkhtmltorpdf-input.html", $html);
$this->updateStatus($document->getId(), 45, "saved_html_file");
try {
$this->updateStatus($document->getId(), 50, "pdf_conversion");
$pdf = $this->fromStringToStream($html);
$this->updateStatus($document->getId(), 100, "saving_pdf_document");
} catch (\Exception $e) {
Logger::error($e);
$document->setLastGenerateMessage($e->getMessage());
throw new \Exception("Error during REST-Request:" . $e->getMessage());
}
$document->setLastGenerateMessage("");
return $pdf;
}