Hello, I use TCPdf for making pdfs. On some nodes, I get a pdf with only the 2 lines at bottom and at the top and the numer of the page on ther bottom-right corner. See the attached file. With these nodes printer and email modules work correctly. What could be the problem?
Thanks for answer.

Comments

suydam’s picture

I'm having the same issue.
What's more, a reporting piece I wrote (that uses manual calls to tcpdf) works just fine.

Drupal 6.15
print.module 6.x-1.10
TCPDF 4_8_022

marrch_caat’s picture

The same problem occures both on 6.x-1.10 version with tcPDF v. 4.8.016 and after upgrade to the latest 6.x-1.x-dev with the latest tcPDF 4.8.036.

marrch_caat’s picture

My investigation leads me to the function _print_pdf_tcpdf() in the print_pdf.pages.inc, to the following lines:

  // Decode HTML entities in image filenames
  $pattern = "!<img\s[^>]*?src\s*?=\s*?['\"]?${base_url}[^>]*?>!is";
  $html = preg_replace_callback($pattern, create_function('$matches', 'return html_entity_decode($matches[0], ENT_QUOTES);'), $html);
  // Remove queries from the image URL
  $pattern = "!(<img\s[^>]*?src\s*?=\s*?['\"]?${base_url}.*?)(?:%3F|\?)[\w=&]+([^>]*?>)!is";
  $html = preg_replace($pattern, '$1$2', $html);

When I replace them with the following:

  // Decode HTML entities in image filenames
  $pattern = "!<img\s[^>]*?src\s*?=\s*?['\"]?{$base_url}[^>]*?>!is";
  $html = preg_replace_callback($pattern, create_function('$matches', 'return html_entity_decode($matches[0], ENT_QUOTES);'), $html);
  // Remove queries from the image URL
  $pattern = "!(<img\s[^>]*?src\s*?=\s*?['\"]?{$base_url}[^>]*?)(?:%3F|\?)[\w=&]+([^>]*?>)!is";
  $html = preg_replace($pattern, '$1$2', $html);

- everything works fine.

frayber’s picture

Status: Active » Fixed

It worked for me!!!
Thank you

marrch_caat’s picture

Status: Fixed » Reviewed & tested by the community

Re-opened the issue so that the module maintainer could notice it and submit the patch to the next release.

victorcoder’s picture

subscribing

jpulles’s picture

Priority: Normal » Critical

This bug seems more or less critical ;-)

The patch above solved the problem when pages with a large table and inline styles failed to print.
Thanks for the solution!

moque’s picture

Version: 6.x-1.10 » 6.x-1.6
Assigned: Unassigned » moque

Hello, I use TCPdf for making pdfs too.
I have use the patch "_print_pdf_tcpdf() in the print_pdf.pages.inc" but my pdf is already empty.

Name: TCPDF

Version: 4.9.015_PHP4

Release date: 2010-04-20

Can you help me ?
Thanks you.

garbo’s picture

I consider this bug critical as well.

And the solution at #3 by marrch_caat fixed the problem for me!

Thanks!

sheetal.nepte’s picture

I am also getting empty page even after applying the above patch.
I have tried with both dompdf and TCPDF.
Please help me. :(

jcnventura’s picture

Status: Reviewed & tested by the community » Fixed

I've just committed this fix to CVS. Thanks!

moque and sheetal.nepte, I will need a URL to the page giving you problems so that I can try to figure out the problem..

Status: Fixed » Closed (fixed)

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

vcardoso’s picture

Version: 6.x-1.6 » 6.x-1.10
Status: Closed (fixed) » Active

Hi João,

I'm facing the same issue after upgrading to Drupal 6.17 and PHP 5.3 (I'm not sure witch one is the responsible). Bellow I'll try to detail the environment for this situation.

Issue
- the "print to pdf" option does not work, it returns a complete blank page (checked it with crtr+u under Firefox)

Development environment
- localhost (Ubuntu 10.04 machine)
- php 5.3.2-1ubuntu4.2
- drupal 6.17
- print-6.x-1.10
- tcpdf_5_5_004

I've tried with the dev version (print-6.x-1.x-dev), but the result remains identical with the additional error message (on the admin area):
- "warning: Parameter 1 to theme_print_pdf_tcpdf_header() expected to be a reference, value given in /home/victor/www/d617-sandbox/includes/theme.inc on line 656."

Also, with the stable version (print-6.x-1.10), I've applied the patch #3 but without any success.

It worked just fine under drupal 6.15 and Ubuntu 09.10 (I'm not sure what was the PHP version at the time).

Thanks in advance for your help.
Victor Cardoso

adrien.gibrat’s picture

Version: 6.x-1.10 » 6.x-1.6
Status: Active » Closed (fixed)

IMHO,
the patch #3 correct a bad pattern ( .*? can eventually "eat" everything)... it's working and resolves a lot of case, it should be commited to the next release!

adrien.gibrat’s picture

Version: 6.x-1.6 » 6.x-1.10
Status: Closed (fixed) » Active

Oops... i closed the ticket by mistake... it's still true on 6.x-1.10 version... the patch resolves my empty pdf problems ;)

gausarts’s picture

Subscribing. Thanks

jcnventura’s picture

Status: Active » Closed (fixed)

Please don't reopen old issues. #13 seems to be a problem with php 5.3 (which makes that a duplicate of #785364: Incompability with php 5.3). #14 and #15 confirm that this is fixed..