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
So the test was successful, but when creating an invoice, there’s something wrong with the PDF.
What could be the issue here?
ben
December 29, 2020, 10:19am
2
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)
ben
December 29, 2020, 12:27pm
4
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.
Install Chromium dependencies. You can find them here .
In your Invoice Ninja directory, run: ./vendor/bin/snappdf download
Edit .env file and set: PHANTOMJS_PDF_GENERATION=false
Run: php artisan optimize
Try to generate PDFs
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.
#!/bin/bash
echo install prerequisites
apt install -y apache2 php mariadb-server php-bcmath php-mbstring php-xml php-curl php-zip php-gmp php-mysqli php-gd wget unzip curl ca-certificates fonts-liberation libappindicator3-1 libasound2 libatk-bridge2.0-0 libatk1.0-0 libcairo2 libcups2 libfontconfig1 libgbm1 libgtk-3-0 libnspr4 libnss3 libpango-1.0-0 libpangocairo-1.0-0 libx11-xcb1 libxcomposite1 libxcursor1 libxdamage1 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 xdg-utils
echo secure mariadb
mysql --user="root" --password="" --execute="SET PASSWORD FOR 'root'@'localhost' = PASSWORD('invoiceninja');"
mysql --user="root" --password="" --execute="DELETE FROM mysql.user WHERE User='';"
mysql --user="root" --password="" --execute="DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');"
mysql --user="root" --password="" --execute="DELETE FROM mysql.db WHERE Db='test' OR Db='test\_%';"
mysql --user="root" --password="" --execute="FLUSH PRIVILEGES;"
echo create database
mysql --user="root" --password="invoiceninja" --execute="CREATE DATABASE invoiceninja;"
mysql --user="root" --password="invoiceninja" --execute="CREATE USER 'invoiceninja'@'localhost' IDENTIFIED BY 'invoiceninja';"
mysql --user="root" --password="invoiceninja" --execute="GRANT ALL ON invoiceninja.* TO 'invoiceninja'@'localhost' IDENTIFIED BY 'invoiceninja' WITH GRANT OPTION;"
mysql --user="root" --password="invoiceninja" --execute="FLUSH PRIVILEGES;"
echo download invoiceninja
wget -P /var/www/html/invoiceninja https://github.com/invoiceninja/invoiceninja/releases/download/v5.0.39-release/invoiceninja.zip
This file has been truncated. show original
ben
December 30, 2020, 10:22am
7
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.