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.
Hi,
thanks for excellent module. International characters are now perfect with TCPDF but I receive error:
TCPDF error: Missing or incorrect image file:
In ommited part there's a "system/files/images" path but files (and thus images) are residing in private folder so they cannot be accessed directly via web. How to resolve this without changing to public method in Drupal configuration?
Sergej
Comments
Comment #1
jcnventura CreditAttribution: jcnventura commentedHi,
The problem is that Drupal simply 'obscures' a real path (usually sites/default/files) by a virtual path (system/files). TCPDF expects to be able to find it in a path relative to the install path of Drupal. Since this path doesn't exist, TCPDF doesn't know where to find it..
A simple solution seems to be to replace all private paths back to the real path..
I am taking a look at it.
João
Comment #2
jcnventura CreditAttribution: jcnventura commentedHi,
I have committed a fix for this, that works, as long as the private path is still relative to the Drupal installation path.
João
Comment #3
SergioGuru CreditAttribution: SergioGuru commentedWell,
great. I believe it works but then how to hide private files so they are not directly accessible from browser? Do you recommend solutions like
http://drupal.org/node/189239 ?
Anyway, thanks for update. I'll change to public files for a while (not much content) but TCPDF with private files is really best combination.
Comment #4
jcnventura CreditAttribution: jcnventura commentedHi,
The problem of making the images truly private is that you either:
a) can see them in a browser (so their URL contains the server root URL, and Drupal's PHP handles the logic of making them accessible). Since TCPDF doesn't know this logic, the files are not be accessible to TCDPF.
b) provide the real internal path in the page, where TCPDF can see them nicely. However the images won't show in the browser.
So the only viable solution currently is to make the private path relative to the
There's also c:
c) Make this module rewrite the image URLs to contain the real path of the image file wherever that may be in the file system.
This last one is not so complicated, but I am focusing on other stuff at the moment.
João
Comment #5
jcnventura CreditAttribution: jcnventura commentedHi.
I have just committed some code which changes the img path to a file:// URL that can be used to access the file wherever it is in the filesystem. It doesn't work for dompdf (it seems that it can't handle the file protocol). For TCPDF, this enables it to access the private files wherever they are in the filesystem.
João
Comment #6
adaven CreditAttribution: adaven commentedHi,
First of all great module, very useful! I've had a go with your latest patch to fix private files, and there are two problems I've come across.
Obviously the first problem can be fixed relatively easily, but the second might be a bit harder.
Comment #7
adaven CreditAttribution: adaven commentedOk, I dug out my old regex reference manual. This seems to work for both clean and unclean urls
I just added a (\?q=)? optional sub-pattern, and replaced $2 with $3 in $replacement.
Comment #8
jcnventura CreditAttribution: jcnventura commentedI committed some similar code to the one you indicated that should handle the unclean URLs.
João
Comment #9
adaven CreditAttribution: adaven commentedThere's still the issue of relative filepaths, but this is a separate issue. I'll create a new issue