Disable live pdf preview in invoice editor?

I’m using InvoiceNinja v5.3.0 via Softaculous with PHP v7.4 on shared hosting (I have an allocation of 2 CPU, 2 GB RAM).

The live PDF preview in the invoice editor has a tendency to crash** and this also interferes with saving changes***.

Even when it’s not crashing, creating/editing large invoices (two to six pages) gets slower and s l o w e r… I don’t actually know whether this is related to the constant updating of the pdf preview as I add / make changes to an invoice but I’m hoping being able to turn live preview off will improve it.

Is there a way to turn it off and just use the manual ‘View PDF’ menu command as needed instead?

** The error displayed instead of the PDF is: PlatformException(error, Promise was rejected with a value of ‘undefine’., null, null)

*** The error displayed is “500: There was an error generating the PDF with Phantom JS”. The invoice will still be saved despite the error message, but attempting to leave the invoice editor page afterwards still behaves as if the changes were not saved (displaying the prompt to continue editing or discard the changes) and the changes only show up in the Invoices section after I force-refresh the webpage in the browser.

P.S. I’m willing to edit my install if that’s what it takes (also if there’s a HOWTO for idiots somewhere that step-by-steps how to manually upgrade a softaculous install to the latest invoiceninja github release I’d appreciate a link). :sweat_smile:

Followup: live PDF preview is pretty much permanently crashed now, reverting to earlier backups briefly works (sometimes) before it fails again.

@shane,

thanks for advising this, can you advised if changing your PDF generation to HOSTED_PDF fixes this issue?

Do I need to do anything other than change the line in the .env file from PDF_GENERATOR=phantom to PDF_GENERATOR=HOSTED_PDF and is it case sensitive?

E.g. any terminal commands I need to run?

not case sensitive,

but you also need to set

PHANTOMJS_PDF_GENERATION=false

Current excerpt from .env file (has the above changes):

NINJA_ENVIRONMENT=selfhost

#options - snappdf / phantom / hosted_ninja
PDF_GENERATOR=hosted_pdf
PHANTOMJS_PDF_GENERATION=false

PHANTOMJS_KEY='a-demo-key-with-low-quota-per-ip-address'
PHANTOMJS_SECRET=secret

Force-refreshed the browser but still giving the error. Clicking on the “Health Check” button in the About section says it’s still using PhantomJS? How can I tell if it’s noticed the change to the .env file? Do I need to ‘reboot’ the app somehow?

php artisan optimize should update settings from .env file.

1 Like

This worked in that the Health Check now shows SnapPDF instead of PhantomJS, but the error is still occurring.

Followup: Trying PDF_GENERATOR=hosted_ninja instead (followed by another optimize) has worked, or at least is working for now. It’s still saying SnapPDF in the Health Check.

Followup 8 Sep: Using hosted_ninja appears to keep the live preview stable in the invoice editor. However, attempting to use the Settings tools to create/edit an invoice design fails (see attached image).

Edit: corresponding error (redacted) in laravel.log is
[2021-09-08 01:48:15] production.ERROR: Downloaded Chromium binary is not executable. Make sure to set correct permissions (0755) {"userId":1,"exception":"[object] (Beganovich\\Snappdf\\Exception\\BinaryNotExecutable(code: 0): Downloaded Chromium binary is not executable. Make sure to set correct permissions (0755) at /(redacted)/invoiceninja/vendor/beganovich/snappdf/src/Snappdf.php:82)

Might be due to using hosted_ninja ?

Having the same issue, but I don’t think it is a problem with the software. It is an issue with the limit of pdf’s on the online phantom pdf generator. Each time a change is made the live preview shoots off another request to the online pdf generator. By the time I’m done editing one invoice, my 500 free pdfs have been used from my phantom account. If you have not made an account yet, then you are probably still using the included key, which will get you even fewer pdf’s. The solution is not to generate the pdf automatically… Does anyone know how to turn off live preview for the pdfs?

There is an option to disable the live preview on Settings > Device Settings

1 Like