When trying to generate a pdf (with TCPDF) from a node containing a gallery generated with the Brilliant Gallery module I get this error:
TCPDF ERROR: [Image] No such file or directory in /my_site_path/sites/all/modules/brilliant_gallery/image.php?imgp=L2hvbWUvcG9ybWVkaWEvcHVibGljX2h0bWwvaWJhY2Evc2l0ZXMvZGVmYXVsdC9maWxlcy9nYWxlcmllcy90ZXJyYXNzYS92aXNpdGVzLzA5MDUwNi9GdXN0YV9kZV9QaV9JcGUuSlBH&imgw=100&imgh=67

It may be related to the issue reported here http://drupal.org/node/420460

Any ideas?

Comments

jcnventura’s picture

Status: Active » Fixed

I have just submitted a modification to the other issues's fix, which should handle your case also.

Can you try the latest dev version and tell me how it went?

João

castawaybcn’s picture

I tested the latest release and everything is working as expected, both the logo and the BG images show as intended.

Thanks a lot!!!

castawaybcn’s picture

Version: 6.x-1.6 » 6.x-1.7
Status: Fixed » Active

sorry to reopen this, but for some strange reason it stopped working. The error changed though:

TCPDF ERROR: [Image] No such file or directory in /my_install_directory/sites/all/modules/brilliant_gallery/image.php

The only reason I can think of is that I updated Drupal's core from 6.11 to 6.12 in the meantime, could this have anything to do with this issue?

jcnventura’s picture

Status: Active » Postponed (maintainer needs more info)

Is that file there?

Also, I don't think this will ever work right.. TCPDF is expecting to find the image in the local filesystem, but the use of the Brilliant Gallery module makes it impossible to know where the image file is, as the only thing provided is a PHP script with a complicated argument that indicates to that module which file you want to see.

castawaybcn’s picture

image.php is there, the images are in the files folder though

jcnventura’s picture

I don't know how it worked before.. There's no way that TCPDF will be able to find that file.. Internally, it will discover that the img URL is in the same server so it will try to access it locally, but index.php is not the image..

You'd have to fool TCPDF somehow by changing the img URLs to appear to be in another server.. The only way would be to have the brilliant gallery module to provide the location of the real file..

João

castawaybcn’s picture

the images are on the same server, but in a different folder (in the site's files folder). What I do not understand about all this is that the images are properly displayed when using the printer friendly version, but I am not a Drupal expert by any means.

jcnventura’s picture

You'd have to be a TCPDF expert to understand it fully.

I've said this in the comments above, but... The web version is created in your browser using external access to your web server. The PDF version is built by TCPDF running inside your server, using internal access to it. Most servers don't allow external access to URLs (even if it is to the same server), so TCPDF tries to access files locally when it discovers that they're running on the same server. In this case, it will always fail, as it tries to access image.php as an image file and not a URL.

castawaybcn’s picture

obrigado for such a good explanation João, and specially for the time you have spent dealing with this since, as it seems, it is not your module's issue at all.
I will try to find a workaround for this issue, should I come across any solution I will post it here. Don't hold your breath though, given my current skills it may take a (really long) while.

jcnventura’s picture

Status: Postponed (maintainer needs more info) » Active

Obrigado myself..

I do have work to do in the module, as the current fix always removes the query in TCPDF-bound pages. I have to change it so that it only removes the query in URLs that are going to be transformed by TCPDF into local file accesses.

Just one final thing: imagine that you have an image at www.example.com/sites/default/files/image.png and Drupal's base URL is www.example.com.. TCPDF will see that the server is the same, and the way I auto-configure TCPDF I tell it that the replacement for www.example.com is /srv/www/htdocs/drupal/..

The problem you have is that it would be better for this code not to work, so in your case, you should probably edit the print_pdf/print_pdf.pages.inc to remove TCPDF's auto-configuration define: define('K_TCPDF_EXTERNAL_CONFIG', TRUE);. Then you have to configure TCPDF in its config file in a way that it always resolves files to external access.

I will also try to add an option in my code to disable the TCPDF auto-config so that you don't have to edit the module's code.

João

jcnventura’s picture

Status: Active » Fixed

Hi,

I have added the option to disable TCPDF's autoconfiguration which should be what you need. Also, the code only removes the queries from local files and not for external img URLs.

With these two changes, it's possible that you may find a TCPDF configuration which doesn't interfere with the Brilliant Gallery module..

João

castawaybcn’s picture

Thanks, will look into it.
Should I assume the fix is in the .dev version?

jcnventura’s picture

Yes, it is.. In your case, as I have explaine above, it won't work out-of-the-box.. What you'll have to do is to disable the module's autoconfig of TCPDF, then edit the tcpdf_config file. You'll have to edit the following vars:

    define('K_PATH_MAIN', dirname($_SERVER['SCRIPT_FILENAME']));
    define('K_PATH_URL', $base_url);
    define('K_PATH_FONTS', $pdf_tool_path .'/fonts/');
    define('K_PATH_CACHE', $pdf_tool_path .'/cache/');
    define('K_PATH_IMAGES', '');
    define('K_BLANK_IMAGE', $pdf_tool_path .'/images/_blank.png');
    define('K_CELL_HEIGHT_RATIO', 1.25);
    define('K_SMALL_RATIO', 2/3);

Note that the code above is the current definition of those vars in the print_pdf.module. You'll have to set the K_PATH_URL in a way that it isn't really the base_url of your site. My recommendation is to set it to http://example.com if your base_url is http://www.example.com or vice-versa (this is assuming that your site can be reached with or without the www). That should fool TCPDF into always doing external URL accesses.

Status: Fixed » Closed (fixed)

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

rsvelko’s picture

offtopic:

#13 was helpful while I was trying to make imagebrowser's dynamic images work with print module's pdf export.

I had to patch the print module's code and tcpdf's code too (2 one line patches, some apache alias directives and a new 10 line shell program were necessary ... )

Please click on my name and write me via my contact form for detailed instructions. After some time I may contribute some patches/docs ...