Module

Archived
Forum
(read-only)

PDF Press

ExpressionEngine 2, ExpressionEngine 3, ExpressionEngine 4, ExpressionEngine 5, ExpressionEngine 6

Back to this add-on's main page
View Other Add-ons From Doug Black, Jr.

     

EE 5 and perfect storm

General

blake783
blake783

Pat,
I upgraded a site to EE5, thought we tested all PDFs and deployed to live site. Well low and behold none of the pdfs are working now. Tested local and sure enough PDF press is giving us fits in EE5.
Even better to make it the perfect storm, it seems our automated database backups have not been working for the last week and no one has a local backup of the old site. So without losing a couple of weeks worth of site updates in the CMS we can’t go back to EE3.

Thus I was wondering if you could help with this.

We have a button that links to :

{exp:pdf_press:save_to_pdf path='_pdf/properties/{entry_id}' attachment='0' filename='{url_title}-flyer.pdf'

when clicked we are getting the following:

Fatal error: Uncaught Error: Class ‘Dompdf\Options’ not found in /mnt/dwg-do-dev-lemp-expansion/work/dev/nesa/system/user/addons/pdf_press/mod.pdf_press.php:286
Stack trace: #0 /mnt/dwg-do-dev-lemp-expansion/work/dev/nesa/system/user/addons/pdf_press/mod.pdf_press.php(259): Pdf_press->_init_new_dompdf(’<html>\n<head>\n ...’, Array)
#1 /mnt/dwg-do-dev-lemp-expansion/work/dev/nesa/system/user/addons/pdf_press/mod.pdf_press.php(164): Pdf_press->_generate_pdf(’<html>\n<head>\n ...’, Array, false, ‘https://devnesa…’)
#2 /mnt/dwg-do-dev-lemp-expansion/work/dev/nesa/system/ee/legacy/libraries/Actions.php(209): Pdf_press->create_pdf()
#3 /mnt/dwg-do-dev-lemp-expansion/work/dev/nesa/system/ee/legacy/libraries/Core.php(527): EE_Actions->__construct(true, Object(Closure))
#4 /mnt/dwg-do-dev-lemp-expansion/work/dev/nesa/system/ee/legacy/controllers/ee.php(59): EE_Core->generate_action(true)
#5 [internal function]: EE->index()
#6 /mnt/dwg-do-dev-lemp-expansion/work/dev/nesa/system/ee/EllisLab/ExpressionEngine/Core/Core.php(241): cal in /mnt/dwg-do-dev-lemp-expansion/work/dev/nesa/system/user/addons/pdf_press/mod.pdf_press.php on line 286

 

I know PDF Press doesn’t officially support EE5 yet, just hoping out of the goodness in your heart you might be able to help out. thanks.

patpohler
# 1
Developer
patpohler

Is there a ‘vendor’ folder under the pdf_press folder? It should have the following sub folders underneath

https://www.dropbox.com/s/tjisdfycw7rez36/Screenshot 2019-08-26 20.50.56.png?dl=0

patpohler
# 2
Developer
patpohler

Hey Blake, see my comment above about the vendor folder. PDF Press 4+ uses composer to load dompdf, so there’s probably something going on with either autoload.php missing in the pdf_press folder or a missing subfolder for vendor.

I’ve updated dompdf to v. 0.8.3 tonight (which handles PHP 7.3 better) and I tested it locally on ExpressionEngine 5.x and PDF Press seems to be working normally. If you want to try the PDF Press 4.0.2 go for it, just be sure everything is copied up to the server.

Hope that helps!

blake783
# 3
blake783

wow Pat, look at you go!
However, I still have the same issue. I even removed the old pdf press directory completely and reinstalled it from scratch with the .0.2 version.  If you have this working then it makes me think that it’s something on our end. I’m currently having the same issue with this site in three different environments. So I’m going to spin up a second test environment and try to run it with no addons except PDF Press and see if it’s something else conflicting.
I’ll let you know if anything comes of that.

patpohler
# 4
Developer
patpohler

Hey Blake, sorry to hear that…what you could do if you have shell/command line access is try to re-download the composer dependencies. In terminal go to the path for the pdf_press add-on.

You’ll need to make sure composer is installed https://getcomposer.org/ on the server

Then run

> composer update

It should try to download all the dependencies

If you’re still seeing errors this command will refresh composer’s autoloader

> composer dump-autoload -o

blake783
# 5
blake783

Thanks Pat.
- yes. I tried deleting the vendor folder and composer install to make sure it had everything earlier, along with composer update. same thing
- ran, composer dump-autoload -o, returned “Generating optimized autoload files”. But still getting the same thing.
- ran everything on my new environment I spun up with no other addons and got the same thing.

Pulled an older EE 3 backup of the site, upgrade to EE 4, it works fine. Upgrade to EE 5.2.6 and it does this. I’m going to take a deep breath, count 10, drink a pot of coffee and come back to this. It’s got to be something simple.

patpohler
# 6
Developer
patpohler

Hmm, I wonder if there’s a conflict somewhere with composer….are there any other plugins or add-ons that might be using dompdf?

patpohler
# 7
Developer
patpohler

Re-reading your post, I used the developer preview of EE5 back in Nov (5.1?). I didn’t realize the latest version is 5.2.6. Let me see if I can upgrade tonight and re-test

blake783
# 8
blake783

sounds good. thanks so much for your quick responses on this.

Doug Black Jr.
# 9
Doug Black Jr.

@Pat, it appears that this line in mod.pdf_press.php:

require 'vendor/autoload.php'

is pulling from the main vendor file. I was able to get this to work by doing:

require PATH_THIRD 'pdf_press/vendor/autoload.php'

Can you confirm this works?

patpohler
# 10
Developer
patpohler

Hey Doug, wow I bet that’s it! I’ll work on that when I get home and test. Thanks for the suggestion!

blake783
# 11
blake783

Doug for the win. Thanks to both you guys for helping knock this out.

patpohler
# 12
Developer
patpohler

Doug you’re the man! I’ve tested your fix and it works perfectly. I’ve pushed up a new update, 4.0.3 with your fix and I’ve updated the composer files for dompdf to optimize the loading of classes.

Doug Black Jr.
# 13
Doug Black Jr.

Awesome! Happy to help!