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.

Comments

pancho’s picture

Priority: Minor » Normal

Confirmed to fix the bug.

crazyben21’s picture

Thanks for the patch. I guess this affects people that uses dompdf?

seagle’s picture

Issue tags: +print to pdf errors

I 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.

jcnventura’s picture

Status: Needs review » Fixed

Fixed 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.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

baghejari’s picture

Version: 7.x-1.x-dev » 6.x-1.17

i 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

internetdevels’s picture

Status: Closed (fixed) » Needs review
StatusFileSize
new2.3 KB

I'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:

jcnventura’s picture

Status: Needs review » Closed (fixed)

Most 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?

internetdevels’s picture

The changes to print.module to prevent notices during non-nodes printing can't be solved by this hack

issue was that some undefined properties of non existing nodes have been used and after defining them notices disappeared

Are you using an hacked version of TCPDF that defines TCPDF::setFooterData() with two arguments?

I've downloaded the latest version(5.9.181) of TCPDF library from http://www.tcpdf.org/download.php

jcnventura’s picture

Hi,

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