Merge pull request #6751 from turbo124/v5-develop

Add a fallback PDF generator if one fails
This commit is contained in:
David Bomba 2021-10-01 08:28:00 +10:00 committed by GitHub
commit 5f6fa2371a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -170,6 +170,15 @@ class CreateRawPdf implements ShouldQueue
if(config('ninja.invoiceninja_hosted_pdf_generation') || config('ninja.pdf_generator') == 'hosted_ninja'){
$pdf = (new NinjaPdf())->build($maker->getCompiledHTML(true));
$finfo = new \finfo(FILEINFO_MIME);
//fallback in case hosted PDF fails.
if($finfo->buffer($pdf) != 'application/pdf; charset=binary')
{
$pdf = $this->makePdf(null, null, $maker->getCompiledHTML(true));
}
}
else {
$pdf = $this->makePdf(null, null, $maker->getCompiledHTML(true));