Hi,

This error has been bugging me for a couple of days.
I searched drupal and other fora but I did not find an exact match to my problem.
Maybe I overlooked it and my post is a duplicate for which I apologize in advance.

After installing print 5.x 4.0 and TCPDF 4.3004 I got the following error when printing nodes containing either png, jpg of gif images

Apart from this issue and some problems I had correctly referencing the logo url, print, print2email and printt2pdftextonly work like a charm.

The error I got when printing nodes with images was as follows:

TCPDF error: Can't open image file: /var/www/web20/web//var/www/web20/drupaldata/..../images/text_logo.png

As you can see part of the document root was duplicated for some reason.

Next to this error came:
* warning: getimagesize(/var/www/web20//var/www/web20/drupaldata/..../images/text_logo.png) [function.getimagesize]: failed to open stream: No such file or directory in /var/www/web20/web/sites/all/modules/print/tcpdf/tcpdf.php on line 3646.
* warning: fopen(/var/www/web20//var/www/web20/drupaldata/....../images/text_logo.png) [function.fopen]: failed to open stream: No such file or directory in /var/www/web20/web/sites/all/modules/print/tcpdf/tcpdf.php on line 3839.
* warning: getimagesize(/var/www/web20/web//var/www/web20/drupaldata/...../images/text_logo.png) [function.getimagesize]: failed to open stream: No such file or directory in /var/www/web20/web/sites/all/modules/print/tcpdf/tcpdf.php on line 3646.
* warning: fopen(/var/www/web20/web//var/www/web20/drupaldata/....../images/text_logo.png) [function.fopen]: failed to open stream: No such file or directory in /var/www/web20/web/sites/all/modules/print/tcpdf/tcpdf.php on line 3839.

My first approach was to check tcpdf_config.php . I tried various solutions but none worked which leaves me doubtful over its use, since tcpdf somehow 'auto-configures' itself.

Then I looked into tcpdf.php and print_pdf.pages.inc

I am a newbie to PHP and only by trial and error a I came to a simple solution to my problem In print_pdf.pages.inc

I made some small changes in the function function _print_pdf_tcpdf

- define('K_TCPDF_EXTERNAL_CONFIG', TRUE);
+ define('K_TCPDF_EXTERNAL_CONFIG', FALSE);

- define('K_PATH_MAIN', dirname($_SERVER['SCRIPT_FILENAME']));
+ define('K_PATH_MAIN', '');

And guess what, it worked!

To give some context for others who might read this post:
drupal version 5.9
php version 5.2
private download enabled
clean url rewrite enabled

Comments

jcnventura’s picture

Status: Active » Closed (duplicate)

Your problem was actually this one: #314521: TCPDF problem with images in private folder. I know that the other is for version 6.x, but since I keep all versions synced, a bug in one is most likely one in the other also.

João