Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm using the module to output PDFs using the mpdf library. In my dev site, it works fine. When I deployed to staging, it doesn't work. URLs like...
mysite.com/printpdf/1234
...redirect to...
mysite.com/1234
And I get this error in my log:
Notice: Undefined variable: pdf in print_pdf_generate_html() (line 551 of /opt/staging/staging.tmei.org/public/sites/all/modules/contrib/print/print_pdf/print_pdf.module).
I believe I have all the module settings and file perms the same in my staging site as they are in my dev site.
Comments
Comment #1
frobI am getting this too.
Comment #2
frobapparently there is no pdf tool enabled. This could probably use some better error handling.
Comment #3
frobsave your settings here and it should remove the notice
admin/config/user-interface/print/pdf
Comment #4
RumpledElf CreditAttribution: RumpledElf commentedWow ok, this is quite the UX issue. And yes, you fix it by going to that path and hitting save but you shouldn't have to go around googling to find that out, when you go to the settings page after installing a library all the right options are pre filled but you still have to hit save.
Comment #5
frobI have not tested this, but this patch should solve the issue. It will not make things work out of the box, but it will make it not error.
The issue is that this function doesn't return anything.
So I am now just preloading the $pdf variable.
Comment #6
candelas CreditAttribution: candelas commented@frob saving the settings in admin/config/user-interface/print/pdf made it!! Thanks
Comment #7
jcnventura CreditAttribution: jcnventura commentedThe problem is that the site would become too slow if the check were done before the call to generate the PDF, and after the call it's already too late.
In any case, the administrator is alerted to the exact nature of the problem in the 'status report' page, where it belongs. I will however add the $pdf wrapper suggested here, as it removes the notices from the log.
Comment #8
pianomansam CreditAttribution: pianomansam commentedSince there isn't a patch and the above code doesn't solve the issue but only suppresses the error, I'm reverting this to needs work.
Comment #9
frobIf you check the code you will see that my suggested fix was already applied. The correct status is fixed.
Comment #10
pianomansam CreditAttribution: pianomansam commentedThat's fine, @frob. Since the original PHP notice is fixed, I'll create a separate related ticket about the need to resubmit the admin form in order to make things work.