Using dompdf, view a PDF version of any node and get following notices:
Notice: Use of undefined constant LANGUAGE_NEGOTIATION_NONE - assumed 'LANGUAGE_NEGOTIATION_NONE' in _print_pdf_file_access_images() (line 108 of ...\sites\all\modules\print\print_pdf\print_pdf.pages.inc).
Notice: Use of undefined constant LANGUAGE_NEGOTIATION_PATH_DEFAULT - assumed 'LANGUAGE_NEGOTIATION_PATH_DEFAULT' in _print_pdf_file_access_images() (line 109 of ...\sites\all\modules\print\print_pdf\print_pdf.pages.inc).
Notice: Use of undefined constant LANGUAGE_NEGOTIATION_PATH - assumed 'LANGUAGE_NEGOTIATION_PATH' in _print_pdf_file_access_images() (line 110 of ...\sites\all\modules\print\print_pdf\print_pdf.pages.inc).
Added quotes around constants. Patch attached.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | print-undefined-constants-notices-1098712-7.patch | 2.3 KB | internetdevels |
| print_print_pdf.pages_.patch | 628 bytes | NoDice |
Comments
Comment #1
panchoConfirmed to fix the bug.
Comment #2
crazyben21 commentedThanks for the patch. I guess this affects people that uses dompdf?
Comment #3
seagle commentedI ran into a similar issue using printpdf and the tcpdf library. I can't find a clear description of how to apply a .patch file but here are the errors I'm generating:
# Notice: Use of undefined constant LANGUAGE_NEGOTIATION_NONE - assumed 'LANGUAGE_NEGOTIATION_NONE' in _print_pdf_file_access_images() (line 108 of /mnt/www/html/microstraindev/docroot/sites/all/modules/print/print_pdf/print_pdf.pages.inc).
# Notice: Use of undefined constant LANGUAGE_NEGOTIATION_PATH_DEFAULT - assumed 'LANGUAGE_NEGOTIATION_PATH_DEFAULT' in _print_pdf_file_access_images() (line 109 of /mnt/www/html/microstraindev/docroot/sites/all/modules/print/print_pdf/print_pdf.pages.inc).
# Notice: Use of undefined constant LANGUAGE_NEGOTIATION_PATH - assumed 'LANGUAGE_NEGOTIATION_PATH' in _print_pdf_file_access_images() (line 110 of /mnt/www/html/microstraindev/docroot/sites/all/modules/print/print_pdf/print_pdf.pages.inc).
# Notice: Use of undefined constant PDF_PRODUCER - assumed 'PDF_PRODUCER' in _print_pdf_tcpdf() (line 254 of /mnt/www/html/microstraindev/docroot/sites/all/modules/print/print_pdf/print_pdf.pages.inc).
# Notice: Undefined index: submitted in _print_pdf_tcpdf() (line 273 of /mnt/www/html/microstraindev/docroot/sites/all/modules/print/print_pdf/print_pdf.pages.inc).
# Notice: Undefined index: taxonomy in _print_pdf_tcpdf() (line 276 of /mnt/www/html/microstraindev/docroot/sites/all/modules/print/print_pdf/print_pdf.pages.inc).
# Notice: Undefined offset: 1 in theme_print_pdf_tcpdf_header() (line 462 of /mnt/www/html/microstraindev/docroot/sites/all/modules/print/print_pdf/print_pdf.pages.inc).
# Notice: Use of undefined constant PDF_PRODUCER - assumed 'PDF_PRODUCER' in theme_print_pdf_tcpdf_page() (line 481 of /mnt/www/html/microstraindev/docroot/sites/all/modules/print/print_pdf/print_pdf.pages.inc).
Any help would be greatly appreciated, thanks.
Comment #4
jcnventuraFixed in git.
The real fix is not simply to use strings.. These used to be valid D6 constants that got changed. However, this is linked to trying to find the correct local path for images.
That functionality is currently totally broken, so for the meantime, the fix is to bypass the whole code.
Comment #6
baghejari commentedi apply patch above and edit print_pdf.pages.inc as following:
function print_pdf_controller()
// $pdf_filename = token_replace($pdf_filename, 'global');
if (empty($pdf_filename)) {
// If there are still tokens, use a fallback solution
$pdf_filename = str_replace('/', '_', $path);
}
it work properly for me
Comment #7
internetdevels commentedI've found many notices/warnings too:
Notice: Undefined property: stdClass::$type in template_preprocess_page() (line 1924 of /includes/theme.inc).
Notice: Use of undefined constant PDF_PRODUCER - assumed 'PDF_PRODUCER' in _print_pdf_tcpdf() (line 302 of /sites/all/modules/print/print_pdf/print_pdf.pages.inc).
Strict warning: Declaration of PrintTCPDF::SetFooterData() should be compatible with that of TCPDF::setFooterData() in module_load_include() (line 288 of /includes/module.inc).
Notice: Undefined index: submitted in _print_pdf_tcpdf() (line 320 of /sites/all/modules/print/print_pdf/print_pdf.pages.inc).
Notice: Undefined index: taxonomy in _print_pdf_tcpdf() (line 323 of /sites/all/modules/print/print_pdf/print_pdf.pages.inc).
Notice: Undefined offset: 1 in theme_print_pdf_tcpdf_header() (line 517 of /sites/all/modules/print/print_pdf/print_pdf.pages.inc).
Notice: Undefined offset: 1 in theme_print_pdf_tcpdf_header() (line 517 of /sites/all/modules/print/print_pdf/print_pdf.pages.inc).
to fix them I've created patch:
Comment #8
jcnventuraMost of the #7 patch was already committed 5 months ago.
http://drupalcode.org/project/print.git/commit/d4f207d410557f928f504a000...
The changes to print.module to prevent notices during non-nodes printing can't be solved by this hack. And the change to print_pdf.class.inc is strange.. Are you using an hacked version of TCPDF that defines TCPDF::setFooterData() with two arguments?
Comment #9
internetdevels commentedissue was that some undefined properties of non existing nodes have been used and after defining them notices disappeared
I've downloaded the latest version(5.9.181) of TCPDF library from http://www.tcpdf.org/download.php
Comment #10
jcnventuraHi,
About "The changes to print.module to prevent notices during non-nodes printing can't be solved by this hack", I realize I didn't explain myself well enough.. I do know why the notices would show up. The question is that you're fixing them by setting a type, but it should be fixed by preventing the use of the var when there's no type.. In fact, I think that might also have been fixed several releases ago.
Thanks for the info on TCPDF's version.. Looking at the changelog, Nicola added a function using the same name I was using before.. I'll probably need to update the code to use his function, for TCPDF >= 5.9.174