Failed to load PDF document after design tests

Hey!
I made a few changes to my PDF design (I tried to replace <div id="client-details"></div> with custom fields). Looks like I made a mistake, now PDFs don’t work anymore. I always get Error - Failed to load PDF document, even after undoing all my changes, saving them and several reloads.
When creating a new invoice I get this error: platformException(error, Promise was rejected with a value of 'undefined0., null, null)
I can’t see anything related to this in the logs, the latest entries are successfully generated PDFs before my changes:

[2021-10-15 10:20:24] production.INFO: https://mydomain.com/phantom/invoice/Jr40TcN1YlbHDAvIMR2MzlYJXxzflF6Qe3pmc7i2WossBzKvGL2QlW1fDAJBpNu3?phantomjs_secret=secret
[2021-10-15 15:22:30] production.INFO: https://mydomain.com/phantom/invoice/uU01jm953zMTCM5YAflw17A82nd0pZKOauWmoN1T6VFnE12EFxc1KoV215vQ9PdI?phantomjs_secret=secret
[2021-10-15 15:22:41] production.INFO: https://mydomain.com/phantom/invoice/uU01jm953zMTCM5YAflw17A82nd0pZKOauWmoN1T6VFnE12EFxc1KoV215vQ9PdI?phantomjs_secret=secret
Do you have any idea what to do?

I tried this:
set PHANTOMJS_PDF_GENERATION=true in .env
run php artisan optimize a few times (see PlatformException(error, Promise was rejected with a value of 'undefined'.,null, null) - #18 by hillel), but now I have an error 500 without any logs, so my IN installation (productive!) is completely broken. Do you have any idea what to do, @hillel, @david? Any help is appreciated!
Thanks a lot and best

Try either

PDF_GENERATOR=phantom

or if that doesn’t work

PDF_GENERATOR=hosted_ninja

David, how are you?..can you investigate this issue…it is very common. I reported similar issue 2 weeks ago and also in my other post 3 days ago. invoice generation is a hit or miss in v5.

1 Like

hey @david, thanks for your reply!
unfortunately, that doesn’t help, as I get an error 500 after running php artisan optimize :frowning: so looks like my system is completely broken…

btw, these are the error logs I got from my hoster:

Hey @david
I get the same error now on a completely different shared hosting. There I can at least see something in the log:
[2021-10-21 13:08:20] production.ERROR: syntax error, unexpected ‘bool’ (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) {“exception”:"[object] (ParseError(code: 0): syntax error, unexpected ‘bool’ (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) at /home/sites/4a/0/02ec6ee49d/public_html/invoiceninja-v5/app/Repositories/BaseRepository.php:32)
[stacktrace]
#0 /home/sites/4a/0/02ec6ee49d/public_html/invoiceninja-v5/vendor/composer/ClassLoader.php(346): Composer\Autoload\includeFile(’/home/sites/4a/…’)
#1 [internal function]: Composer\Autoload\ClassLoader->loadClass(‘App\\Repositorie…’)
#2 /home/sites/4a/0/my.provider/public_html/invoiceninja-v5/app/Repositories/InvoiceRepository.php(21): spl_autoload_call(‘App\\Repositorie…’)
#3 /home/sites/4a/0/my.provider/public_html/invoiceninja-v5/vendor/composer/ClassLoader.php(478): include(’/home/sites/4a/…’)
#4 /home/sites/4a/0/my.provider/public_html/invoiceninja-v5/vendor/composer/ClassLoader.php(346): Composer\Autoload\includeFile(’/home/sites/4a/…’)
#5 [internal function]: Composer\Autoload\ClassLoader->loadClass(‘App\\Repositorie…’)
#6 [internal function]: spl_autoload_call(‘App\\Repositorie…’)
#7 /home/sites/4a/0/my.provider/public_html/invoiceninja-v5/vendor/laravel/framework/src/Illuminate/Container/Container.php(833): ReflectionClass->__construct(‘App\\Repositorie…’)
#8 /home/sites/4a/0/my.provider/public_html/invoiceninja-v5/vendor/laravel/framework/src/Illuminate/Container/Container.php(714): Illuminate\Container\Container->build(‘App\\Repositorie…’)
#9 /home/sites/4a/0/my.provider/public_html/invoiceninja-v5/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(841): Illuminate\Container\Container->resolve(‘App\\Repositorie…’, Array, true)
#10 /home/sites/4a/0/my.provider/public_html/invoiceninja-v5/vendor/laravel/framework/src/Illuminate/Container/Container.php(652): Illuminate\Foundation\Application->resolve(‘App\\Repositorie…’, Array)
#11 /home/sites/4a/0/my.provider/public_html/invoiceninja-v5/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(826): Illuminate\Container\Container->make(‘App\\Repositorie…’, Array)
#12 /home/sites/4a/0/my.provider/public_html/invoiceninja-v5/vendor/laravel/framework/src/Illuminate/Container/Container.php(987): Illuminate\Foundation\Application->make(‘App\\Repositorie…’)
#13 /home/sites/4a/0/my.provider/public_html/invoiceninja-v5/vendor/laravel/framework/src/Illuminate/Container/Container.php(907): Illuminate\Container\Container->resolveClass(Object(ReflectionParameter))
#14 /home/sites/4a/0/my.provider/public_html/invoiceninja-v5/vendor/laravel/framework/src/Illuminate/Container/Container.php(868): Illuminate\Container\Container->resolveDependencies(Array)
#15 /home/sites/4a/0/my.provider/public_html/invoiceninja-v5/vendor/laravel/framework/src/Illuminate/Container/Container.php(714): Illuminate\Container\Container->build(‘App\\Console\\Com…’)
#16 /home/sites/4a/0/my.provider/public_html/invoiceninja-v5/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(841): Illuminate\Container\Container->resolve(‘App\\Console\\Com…’, Array, true)
#17 /home/sites/4a/0/my.provider/public_html/invoiceninja-v5/vendor/laravel/framework/src/Illuminate/Container/Container.php(652): Illuminate\Foundation\Application->resolve(‘App\\Console\\Com…’, Array)
#18 /home/sites/4a/0/my.provider/public_html/invoiceninja-v5/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(826): Illuminate\Container\Container->make(‘App\\Console\\Com…’, Array)
#19 /home/sites/4a/0/my.provider/public_html/invoiceninja-v5/vendor/laravel/framework/src/Illuminate/Console/Application.php(260): Illuminate\Foundation\Application->make(‘App\\Console\\Com…’)
#20 /home/sites/4a/0/my.provider/public_html/invoiceninja-v5/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(232): Illuminate\Console\Application->resolve(‘App\\Console\\Com…’)
#21 /home/sites/4a/0/my.provider/public_html/invoiceninja-v5/vendor/laravel/framework/src/Illuminate/Console/Application.php(151): Illuminate\Foundation\Console\Kernel->Illuminate\Foundation\Console\{closure}(Object(Illuminate\Console\Application))
#22 /home/sites/4a/0/my.provider/public_html/invoiceninja-v5/vendor/laravel/framework/src/Illuminate/Console/Application.php(74): Illuminate\Console\Application->bootstrap()
#23 /home/sites/4a/0/my.provider/public_html/invoiceninja-v5/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(330): Illuminate\Console\Application->__construct(Object(Illuminate\Foundation\Application), Object(Illuminate\Events\Dispatcher), ‘8.40.0’)
#24 /home/sites/4a/0/my.provider/public_html/invoiceninja-v5/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(129): Illuminate\Foundation\Console\Kernel->getArtisan()
#25 /home/sites/4a/0/my.provider/public_html/invoiceninja-v5/artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#26 {main}
"}

The error looks like it may be from using PHP < 7.4

oh, then this error isn’t related to the PDF bug at all - I did set up the queue cron and by mistake used PHP 7.3 first.
I’m definitely on PHP 7.4:
image

It looks like the CLI version is PHP 7.1.

You can run php -v from the command line to check.

@david I think php_version.is_okay should return false in this case

I know, but I can manually choose another PHP version in the CLI.
Nonetheless, I think that’s not related to the PDF issue, as it used to work very well.
I was working on a quote, and suddenly I got this PDF error.

It even doesn’t work anymore after restoring a backup :frowning:
and just to be clear: i have the same bug on two completely different systems on completely different shared hostings!

@lucaw

What is the value of

PDF_GENERATION=

if you .env file?

ensure you have either

phantom
hosted_ninja

or

snappdf

@david
PDF_GENERATOR or PDF_GENERATION?

The value is PDF_GENERATOR=phantom, but I’m going to change to PDF_GENERATOR=hosted_ninja, let’s see if that helps…

SO ALL THIS WHILE…PDF GENERATIO ISSUES could have been SOLVED simply by USING hosted_ninja instead of phantom??? …tears😢

I redraw my post…it still doesnt work…invoice generation is a big problem in this V5…its make the whole program UNUSEABLE…if you email an invoice to a customer, it wont go with the IMAGE ICON that they have to click to view invoice, that means your invoice cannot be view in the client portal. …i have to separate ninjas on 2 separate servers, one is only local and other is accessed with https. the local is a clone of the https…what i learnt is, from a fresh start, you can view any invoice but soon, it will start giving an error, then you jump to another company, you are able to view the invoices there and soon they also stop opening…then you can create a new invoice which will open fine even though the old invoice wont open in pdf…until after you try to reopen any of the old invoices then the issue will now affect the new one that was just opening fine…leaving you with no opening invoice at all…now, if i open the invoice for editing, then click save as if i changed anything, it will save then during the save progress, the sample invoice will now be generated at the bottom of the editing page…but if you try to view invoice in pdf, you will get a blank page or an error

it looks as if the pdf generator get tired and fed of generating invoices…using snappdf or hosted_ninja doesn’t fix anything.
also, can you re-add the close button the invoice editing page…there is only save and cancel. …maybe change cancel to close to get out of the page after saving the changes