public function startPdfGeneration($documentId)
{
$jobConfigFile = $this->loadJobConfigObject($documentId);
$document = $this->getPrintDocument($documentId);
// check if there is already a generating process running, wait if so ...
Model\Tool\Lock::acquire($document->getLockKey(), 0);
try {
\Pimcore::getEventManager()->trigger("document.print.prePdfGeneration", $document, ["processor" => $this]);
$pdf = $this->buildPdf($document, $jobConfigFile->config);
file_put_contents($document->getPdfFileName(), $pdf);
\Pimcore::getEventManager()->trigger("document.print.postPdfGeneration", $document, ["filename" => $document->getPdfFileName(), "pdf" => $pdf]);
$creationDate = \Zend_Date::now();
$document->setLastGenerated($creationDate->get() + 1);
$document->save();
} catch (\Exception $e) {
$document->save();
Logger::err($e);
}
Model\Tool\Lock::release($document->getLockKey());
Model\Tool\TmpStore::delete($document->getLockKey());
@unlink($this->getJobConfigFile($documentId));
}