Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #1
jcnventura CreditAttribution: jcnventura commentedI 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
Comment #2
castawaybcn CreditAttribution: castawaybcn commentedI tested the latest release and everything is working as expected, both the logo and the BG images show as intended.
Thanks a lot!!!
Comment #3
castawaybcn CreditAttribution: castawaybcn commentedsorry to reopen this, but for some strange reason it stopped working. The error changed though:
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?
Comment #4
jcnventura CreditAttribution: jcnventura commentedIs 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.
Comment #5
castawaybcn CreditAttribution: castawaybcn commentedimage.php is there, the images are in the files folder though
Comment #6
jcnventura CreditAttribution: jcnventura commentedI 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
Comment #7
castawaybcn CreditAttribution: castawaybcn commentedthe 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.
Comment #8
jcnventura CreditAttribution: jcnventura commentedYou'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.
Comment #9
castawaybcn CreditAttribution: castawaybcn commentedobrigado 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.
Comment #10
jcnventura CreditAttribution: jcnventura commentedObrigado 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
Comment #11
jcnventura CreditAttribution: jcnventura commentedHi,
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
Comment #12
castawaybcn CreditAttribution: castawaybcn commentedThanks, will look into it.
Should I assume the fix is in the .dev version?
Comment #13
jcnventura CreditAttribution: jcnventura commentedYes, 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:
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.
Comment #15
rsvelko CreditAttribution: rsvelko commentedofftopic:
#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 ...