Test PDF button working, invoice PDF not working

During initial setup of invoiceninja v5, I click on the “Test PDF” button and get a “Success” message.

When I download the PDF I can open it just fine, all 8 pages of it.

But when I create an invoice in invoiceninja, download it and try to open it, I get this

22

So the test was successful, but when creating an invoice, there’s something wrong with the PDF.

What could be the issue here?

Hey there,

Thanks for reporting this to us. One weird thing to me, you said:

… I can open it just fine, all 8 pages of it.

Test PDF should contain “Generating PDFs works” message, not 8 pages. Can you attach the PDF you get on setup?

Also, can I know how you installed Invoice Ninja? Is it using Docker, some guide here on the forum or you did it manually?

Thanks!

I downloaded test.pdf from /var/www/html/invoiceninja/public/storage
I can’t upload a pdf here, so I attached a screen shot of it.

None of these guides are working for me so I am trying different methods, and slowly building a script.
guide1
guide2

This is the script I’ve build so far, and this is what I used for the installation.

I am installing on Debian 10, using Apache2, PHP7.3 (no certificate)

This means you’re using PhantomCloud to generate PDFs. We also offer our official way to generate PDFs locally without depending on external service.

Here’s how you can do it.

  1. Install Chromium dependencies. You can find them here.
  2. In your Invoice Ninja directory, run: ./vendor/bin/snappdf download
  3. Edit .env file and set: PHANTOMJS_PDF_GENERATION=false
  4. Run: php artisan optimize

Try to generate PDFs :+1:

Yes, this seems to get the job done. Now pdf’s are working.

The one thing I couldn’t figure our is what is so special about the snappdf command.

I am trying to run it from a bash script like this “/var/www/html/invoiceninja/vendor/bin/snappdf download” but I get an access denied arror. Whereas if I run it manually it works fine.

I also tried

  • . /var/www/html/invoiceninja/vendor/bin/snappdf download
  • source /var/www/html/invoiceninja/vendor/bin/snappdf download
  • cd /var/www/html/invoiceninja/vendor/bin && ./snappdf download
  • cd /var/www/html/invoiceninja && ./vendor/bin/snappdf download

But only running it manually in the terminal actually works.

This was the solution
php /var/www/html/invoiceninja/vendor/bin/snappdf download

And this is the script that installs invoiceninja5 on Debian 10 using Apache2.

Happy you got it working. Keep in mind that snappdf downloads new Chromium build each time (assuming you run it more often than every 15 minutes).

It might be a good idea to remove older versions, after some time, because they’ll take up your space pretty quickly. I plan to add support for this natively pretty soon.

To get the latest version you can use the following:

cat vendor/beganovich/snappdf/versions/revision.txt
839728-Linux_x64

Also, it’s fine to run download command every month or 20ish days. No need to do it more often that that.