Invoice PDF generated with wrong content (grey page)

Hi,

I’m using a self-hosted invoiceninja5 version (via Yunohost - v5.3.60-C76) on a raspberryPI.

I have had errors trying to generate PDF invoices (500 server error) that I solved from the information I found here and there on the forum and documentation. Mainly I modified my .env file to use PhantomJS (with a private key).

The health check is mostly green as you can see below (don’t know what Queue is, and the snapPDF warning seems normal since I can’t use it on a self-hosted installation and use Phantom JS instead):

image

So when I edit a draft invoice I can see a preview using the choosen template, but when I try to view the PDF or download it, I see a single page pdf which shows a grey page with no content and two white dots.

It seems to me that the dots are “loading dots” from a view that is being loaded and that you can see sometimes in the app (for example when you do a CTRL+R).

I didn’t find anything about this type of error. And the result is the same when I use the Linux app.

I would appreciate help pointing to information about similar error, or where I can find relevant log info.

Thanks !

Here is the output pdf:

And here is what I see in Firefox console:

image

(sorry I can only post one image per post as a new user…)

Hi,

Are you able to view the PDF in the client portal?

@david do you have any thoughts?

I dont understand how to view the corresponding invoice in the client portal… How should I do that ?

I do not have a “client” account, and I suppose you don’t mean logging “as” the client ?
And the invoice is still a draft so it can’t be seen on the client portal I guess.

You can copy/paste the client portal link from the edit invoice page near the contact details.

Thanks, I just checked and the pdf displayed in the client portal is also a grey page.

Have you seen the info here:

https://invoiceninja.github.io/docs/self-host-troubleshooting/#pdf-conversion-issues

@david do you have any suggestions?

Yes I have, and this is how I got Phantom JS to generate a pdf and solve the 500 server error.

In laravel.log there are no more errors now, I can see the errors from before when I was trying to generate a pdf with snappdf before understanding that it does not work on a self-hosted instance. Edit: Actually it is written in the doc that it’s not possible in a shared hosting which I misread in self-hosted…

I added the LOG_PDF_HTML=true variable in .env as I understand I should see the content that is supposed to be converted to PDF, but there is nothing in the laravel.log… is it supposed to be logged elsewhere ?

Edit2: with snappdf I can see html dump into the logs, but when using phantomJS there is no html dump in the log…

Also I have a doubt now, I thought I read in the documentation (but can’t find it anymore) that using snappdf was not compatible with a linux system. Is this correct ?

Because I tried again using snappdf and I now run again in the 500 server error.

Could it be that my raspberryPI is 32-bit and that I don’t have the correct snappdf version ? Here is the log error:

[2022-05-06 12:17:39] production.ERROR: The command "'/var/www/invoiceninja5/vendor/beganovich/snappdf/versions/973315-Linux_x64/chrome-linux/chrome' '--headless' '--disable-gpu' '--disable-translate' '--disable-extensions' '--disable-sync' '--disable-background-networking' '--disable-software-rasterizer' '--disable-default-apps' '--disable-dev-shm-usage' '--safebrowsing-disable-auto-update' '--run-all-compositor-stages-before-draw' '--no-first-run' '--no-margins' '--no-sandbox' '--print-to-pdf-no-header' '--hide-scrollbars' '--ignore-certificate-errors' '--print-to-pdf=/tmp/pdf_QVPbfY.pdf' '/tmp/html_HVY5xm.html'" failed.

Exit Code: 2(Misuse of shell builtins)

Working directory: /var/www/invoiceninja5/public

Output:
================


Error Output:
================
sh: 1: exec: /var/www/invoiceninja5/vendor/beganovich/snappdf/versions/973315-Linux_x64/chrome-linux/chrome: Exec format error
 {"userId":1,"exception":"[object] (Symfony\\Component\\Process\\Exception\\ProcessFailedException(code: 0): The command \"'/var/www/invoiceninja5/vendor/beganovich/snappdf/versions/973315-Linux_x64/chrome-linux/chrome' '--headless' '--disable-gpu' '--disable-translate' '--disable-extensions' '--disable-sync' '--disable-background-networking' '--disable-software-rasterizer' '--disable-default-apps' '--disable-dev-shm-usage' '--safebrowsing-disable-auto-update' '--run-all-compositor-stages-before-draw' '--no-first-run' '--no-margins' '--no-sandbox' '--print-to-pdf-no-header' '--hide-scrollbars' '--ignore-certificate-errors' '--print-to-pdf=/tmp/pdf_QVPbfY.pdf' '/tmp/html_HVY5xm.html'\" failed.

Exit Code: 2(Misuse of shell builtins)

Working directory: /var/www/invoiceninja5/public

Output:
================


Error Output:
================
sh: 1: exec: /var/www/invoiceninja5/vendor/beganovich/snappdf/versions/973315-Linux_x64/chrome-linux/chrome: Exec format error
 at /var/www/invoiceninja5/vendor/beganovich/snappdf/src/Snappdf.php:223)
[stacktrace]
#0 [...]

It could be related to raspberryPI, @david may know more…

@raphm

It looks like the system won’t allow InvoiceNinja to run a cli command to execute the snappdf binary. You’ll need to either use PhantomJS or hosted_ninja for your PDF generation.

Thanks for your feedback @david.

The thing is that the grey PDF page occurs using phantomJS, and that in that case there is absolutely nothing in laravel.log (except one line which seems to say that the PDF was produced without problems…).

Also with phantomJS there is no HTML dump in the log (with LOG_HTML_PDF set to true) while there is one when I tried using snappdf.

@raphm

Is your instance accessible over http? phantomJS needs to access your machine to read the HTML.

PhantomJS won’t output LOG_HTML_PDF, this is only used for snappdf currently.

I would suggest trying hosted_ninja

Well http returns 301 moved permanently since it is redirected to https… But if you’re asking if my instance is public, yes it is.

Thanks for the explanation for the log output.

hosted_ninja works with white label licence only if I understand correctly…