Failed to load PDF Document

Hi Good day everyone, i have installed v5.1.31 using softaculous and done migration from version 4.5.35. At first,

Im on shared server and my hosting didnt gave me ssh access and such, so im kind of stuck with whatever accessible via cpanel.

Im facing the issues of failed to load PDF Document. is there anyway to troubleshoot this?

And along with this, it seems i also failed to convert quote to invoice


Have you seen the info here:

Thanks for the reply “php artisan optimize” how can i do it on shared hosting as i mention above yea?

can this be done?

@david, any thoughts?

Dear Sir @hillel , upon continuing reading, i saw that white level user didnt use phantom pdf?

So if i purchased white label, was it meant i didnt need phantom js step and those command anymore?


White label users are able to switch their PDF generator away from PhantomJS and point it towards our servers, correct.

Edit, nevermind, it seems i found the solution, somehow, invoiceninja kind of stored cache on my browser which causes it to still follow the old .env settings.

By using f12 in chrome and empty cache and hard reload, the issues goes away

New update, after a few successfull generate, suddenly the pdf generator failed again, when seeing at the log in /storage/logs/laravel.log

This is when it successfully generate;

[2021-03-26 22:20:41] production.INFO:
[2021-03-26 22:20:55] production.INFO:
[2021-03-26 22:21:57] production.INFO:
[2021-03-26 22:22:30] production.INFO:

After few sucess, suddenly it start request for phantomjs again;

[2021-03-26 22:23:53] production.INFO:
[2021-03-26 22:27:51] production.INFO:
[2021-03-26 22:28:51] production.INFO:
[2021-03-26 22:33:43] production.INFO:
[2021-03-26 22:40:55] production.INFO:

Allright, it seems, that running the php artisan optimize is very important to clear the app cache to avoid such issues So for those who cannot do so, will face such trouble like an issues on generating pdf. For those who cant, might want to try first raise a ticket to hosting tech team. You didnt need to go into too many details, just said as per below;

–Ticket Start–
Hi Support, im just installed Invoice Ninja v5 into the server, and after some configuration, it needed me to run the below command to get the result of the configuration, can you assist?

command needed : php artisan optimize

Documentation; Free Open-Source Invoicing, Expenses & Time-Tracking | Invoice Ninja
–Message end—

Usually they wont asked many question and just do it for you, but in some cases if these failed, then the below might be temporary solution for you.

Disclaimer: Im not an expert nor pro, so i cant say that this will solve your issues and permanently solved it, but in my case, atleast until this time of comment, my pdf has worked as intended. And also please take note, im white label user, which means i purchased the 1 year subscription license as such i didn’t try on default phantomJS configuration. Try at your own risk.

First as a white lable user, i follow this step to disable phantom JS and use self hosted Ninja_hosted_PDF in the /.env file on the invoiceninja root directory. But this changes seems not reflecting or somehow didnt update the cache. Which means the pdf request kept requesting from phantomjs instead ninja_hosted_pdf.

So as i said, i cant run the php artisan optimize command due to server limitation, because of that i highly suspect that its a cache issues. So i found on this site about laravel caching storage discussion php - Laravel 5.3 - Clear config cache in shared hosting - Stack Overflow

So it seems laravel save a cache of its config here: /bootstrap/cache/config.php

inside it you can search for these line:

‘phantomjs_pdf_generation’ => true,

‘invoiceninja_hosted_pdf_generation’ => false,

which DID NOT reflect my settings on /.env so what i do is i simply change phantomjs to false and hosted pdf to true as per below

‘phantomjs_pdf_generation’ => false,

‘invoiceninja_hosted_pdf_generation’ => true,

And my pdf generator worked as it should be. Alhamdulillah. But again, as i no expert, i dont know if this manual settings gonna stay or will change because of maybe this way is improper way of doing it and might get rewritten by the system or something later on. But for the time being, its working, and i also try looked into another hoster that can offer me assistance on doing this php artisan command thingy.

Not forgotten too, Thanks to @hillel @david for the help you guys do and built the wonderful products

It’s no fun with PDF generation.



Even if I run “php artisan optimize” several times it does not work. It always works for a while and then this error occurs again. After a few hours it usually works again.


production.ERROR: There was an error generating the PDF with Phantom JS {"userId":1,"exception":"[object] (App\\Exceptions\\PhantomPDFFailure(code: 0): Ther
e was an error generating the PDF with Phantom JS at /html/ninja/app/Utils/PhantomJS/Phantom.php:135)

What can I do to make the PDF generation work reliably?


Can you please try running THE URL Shortener - Free, Custom URLs

Can you also advise if you are on the latest version of the app.

I am testing with 5.3.0-C58 and 5.3.1-C58 on different servers.
The problem occurs with both.


For some reason even thou you are changing the .env vars to point towards our Hosted PDF, your system continues to try to use Phantom.

Are you using QUEUE_CONNECTION=sync or database?

Perhaps your queue needs to restart with php artisan queue:restart

I suspect the error was due to: “PDF_GENERATOR=phantom”.
I now have the following settings:


In the moment it works. I hope it remains stable.

Which setting is advisable for “QUEUE_CONNECTION”?