Hi there,

The module is working fine if drupal file system is set to public. When I try to set the file system to private, I get the following error :

TCPDF ERROR: [Image] Unable to get image: http://xxxxxx.com/system/files/styles/large/private/test/main-picture/ma...

I can access the picture with the direct link but TCPDF seems to have some problems with it.

I tried :
- To modify php.ini (allow_url_fopen = On; allow_url_include = On;)
- To modify the tcpdf cache folder permissions to 777
- To update the tcpdf config file following this post instructions http://drupal.org/node/1220408#comment-5732246

Does anybody has the pictures displaying in there pdf view while being in private file system mode ?
Any idea what I could try ?


Drupal version : 7.12
Views PDF version : 7.x-1.x-dev


krem’s picture

No ideas so far ? Anybody could just confirm the problem ? Or not ?

drupadawan’s picture

Having similar isue. I have a QR-code (generated with the barcode module) but when I try to generate the pdf with the QR-code image (.png) in it I get:
TCPDF ERROR: [Image] Unable to get image: http://localhost:8080/drupac/sites/default/files/barcodes/0a0cd8c000bc7b...

maniosullivan’s picture

Having a similar issue when trying to add a .PNG to a PDF.

TCPDF ERROR: [Image] Unable to get image: http://somesite.com/sites/default/files/some_image(14).png?1334900150

Have tried changing permissions on files directory. I do not think that this is a permissions issue.

firebird’s picture

This happens if the anonymous users don't have the permission to view the images. The HTML given to the TCPDF library has the image URLs in relative format "/path/to/image".

On line 23092 of tcpdf.php:

// replace relative path with real server path
if (($tag['attribute']['src'][0] == '/') AND !empty($_SERVER['DOCUMENT_ROOT']) AND ($_SERVER['DOCUMENT_ROOT'] != '/')) {

The URLs are converted to absolute URLs, and then fetched with cURL. Since cURL is basically an anonymous user, it can't get the images.

I'm working on a solution.

EDIT: Also, you need to solve this issue first: http://drupal.org/node/1420812 . If your images are orphaned, they can't be downloaded by anyone. This should be obvious even before trying to generate the PDF, though.

firebird’s picture

Status: Active » Needs review
2.65 KB

And here's the patch. It is a bit hacky, since it uses HTTP-requests to check for access to the file in question. Nonetheless, it works for me.

firebird’s picture

And here's another version that can deal with absolute URLs in the src-attribute.

cluther’s picture

I'm experiencing this issue, but even with Drupal set to public file system. (Views_PDF works on my local dev box but not on our VPS and the TDPDF examples work on the VPS).

The error:
TCPDF ERROR: [Image] Unable to get image: http://kb.myvps.net/sites/default/files/styles/large/public/images/IMG_3...

However I can view this file directly in the browser.

Following Clem's lead I've:
- Modified php.ini (allow_url_fopen = On; allow_url_include = On;)
- CHMOD the tcpdf cache folder permissions to 777
- Updated tcpdf_config.php to point to my sites/default/files folder.

I tried applying both patches, however getting and error:

patch < views_pdf-issue_with_private_files-1509534-5.patch 
patching file views_pdf_template.php
Hunk #1 FAILED at 398.
1 out of 1 hunk FAILED -- saving rejects to file views_pdf_template.php.rej

Suggestions anyone?

Thanks in advance,


JohnnyX’s picture

Same problem. Following here...

glajman’s picture

Does anyone know if this BUG is being reviewed ? We have experienced this problem on our site.

firebird’s picture

Have you tried applying the patches with "git apply PATCHFILENAME"?

janchojnacki’s picture

For those who are using 7.x-1.0-rc1, not dev version - I created a patch. Just to not duplicate issue. I don't forget about write permission to sites/all/libraries/tcpdf/cache

firebird’s picture

Here are new patches, with a bug fix that has to do with multilingual URLs that have language prefixes in them.

Image URLs starting with for example en/system/files* instead of system/files* will fail with the previous patches.

nandwabee’s picture

I am trying to apply these patches. Am using rc1 at the moment and I get the following error "The patch cannot be applied in the selected context". What could I be doing wrong?

gillarf’s picture

@nandwabee - read the Drupal documentation on applying patches:



gillarf’s picture

I'm having this issue, but can't get this patch to work.

Do I need to take any other steps other than applying the patch (there is mention of CHMODDING some folders above)

firebird’s picture

Did you notice this in #4 ?

"EDIT: Also, you need to solve this issue first: http://drupal.org/node/1420812 . If your images are orphaned, they can't be downloaded by anyone. This should be obvious even before trying to generate the PDF, though."

gillarf’s picture

I'm not using file entity module as i'm using media 7.x-1.0.

This worked on my local machine, but when i uploaded to a hosted server, I got the error.

firebird’s picture

The error message mentioned in the original post? ("Unable to get image...")

The TCPDF library uses, by default, a cache directory in the library directory (which isn't the right place at all for a cache directory, but that's a different story).

So, the directory at /sites/all/libraries/tcpdf/cache should be writable by the web server. Is it?

gillarf’s picture

Thanks for your help @firebird

Yes its the same issue - TCPDF ERROR: [Image] Unable to get image: [mysite]/sites/default/files/styles/journal/public/DSC05246.JPG

And the tcpdf cache folder is writable by the server. In fact it is 777 at the moment.

BUT, looking at the address above in my error, that file does not exist.

What would cause that - do you know?

EDIT: the file was there, i hadn't refreshed - DOH.

So I have the original issue, despite having patched the module.

firebird’s picture

Is this directory there and writable? [mysite]/sites/default/files/styles/journal/public/

vegansupreme’s picture

I've applied the patch (rc1) but I'm still getting TCPDF ERROR: [Image] Unable to get image:…
When I check the logs, it says the user was anonymous. Is the patch supposed to allow TCPDF to access the files as the current user? If so, that doesn't seem to be happening for me.

gillarf’s picture


Apologies for slow reply - *somehow* this just seemed to suddenly work....

Thanks for your help, I think it was a permission problem.

I still have folders set to 777 though - do you know what they should be?

firebird’s picture

This issue was / is a complete pain in the ass to debug. I saw the same error messages all of you are seeing several times, with different configurations and directory permissions. I'm afraid I can't really help you much more.

@vegansupreme: As to what the patch does: When generating the pdf, normally the TCPDF library uses cURL to fetch the images that it then adds to the pdf. If anonymous users don't have the permission to view the images, you'll get the error. The workaround is to load the images in Drupal with the logged in user, and base64-encoding the images in the document being sent to TCPDF, so it doesn't need to do the cURL requests.

In other words, this patch _only_ helps you if your problem is caused by your Drupal permissions set so that anonymous users can't see the images.

@gillarf: 777 is a bit too much. I'd recommend 775, with the owner / group of the directory set to your shell user / the web server user's group respectively. If your web server is running on your user account, 755 is enough.

gillarf’s picture

@firebird thanks - much appreciated.

Simon Georges’s picture

Can someone summarize the issue for me? Is there actually something to fix there?

gillarf’s picture

I think #4 describes the problem. TCPDF accesses files as an anonymous user, so if anonymous user does not have permission to access the files, there is an error.

The patch worked for me.

@firebird should be able to explain better than I.

Simon Georges’s picture

Ok, thanks, I'll try to see if I can commit it.

maxplus’s picture


I have tried patch #12 on Views pdf rc1 but that did not help.
My cache folder inside TCPDF has permissions 777.
I also set permissions to 777 from my sites/default/files, but that didn't help

I still get the error "TCPDF ERROR: [Image] Unable to get image: .... sites/all/libraries/tcpdf/cache/...."

gillarf’s picture


What about the permissions for the actual file? Did you refresh the cache?

agnese.stelce’s picture

Hi maxplus!

I created a patch which changes the cache directory to solve this problem. Mybe it could be useful for you also. See here - http://drupal.org/node/1220408#comment-7096938

maxplus’s picture

Hi agnese.stelce,

thanks for the effort but I really need to use the rc1 version of views pdf because I need the php fields to create columns.
The patch doesn't work on the rc1 version, maybe I should try to make the changes manually?

agnese.stelce’s picture

yes, patch is against 7.x-1.0 but you can try those changes manually - it should work also on rc1.

killua99’s picture

The patch that the comment #30 mention its done here #1220408: tcpdf is trying to write in /sites/all/libraries/tcpdf/cache I'll need more information

killua99’s picture

Priority: Major » Normal
Status: Needs review » Postponed (maintainer needs more info)
Issue tags: -image, -tcpdf +Needs steps to reproduce

Dear fellow Drupal enthusiasts,

I have set this issue to "Postponed (Maintainer needs more information)".

If not already done please add an issue summary and steps how to reproduce the problem.
And please read again, "Making an issue report".

Help about how to do this can be found on IRC and in the user groups.

After there is new information, please re-open the issue by changing the status to active.

This issue was edited with the help of Issue Helper

killua99’s picture

Issue summary: View changes

Adding php.ini modification

killua99’s picture

Issue summary: View changes
Status: Postponed (maintainer needs more info) » Closed (works as designed)

Please open a new issue if you still have this problem.

Deciphered’s picture

Try the Image Base64 Formatter module, solved the issue for me with PDF Archive.

Rob Rutten’s picture

I ran into this topic while looking for my particular problem with Views PDF:

TCPDF ERROR: [Image] Unable to get image: /storage/web/public/modules/file/icons/text-plain.png

I.e. I have a view with files attached, displayed as a file table (which includes text-plain.png in file / Drupal core). The problem is that the path "/storage/web/public" doesn't exist and I do not know why or where it is generated. The particular image is located at /modules/file/icons/text-plain.png...

I am using a private filesystem and running a multi-site setup, but I'm not sure it has anything to do with this particular issue. I've applied the supplied patches and even installed the Image Base64 Formatter, but so far to no avail.

Any suggestions?

killua99’s picture

Did you try permissions thing? or try to move the file ? I guess I never see an image inside any module. Might be that the reason? try to move the image and test if continue the error.

simone960’s picture

Is this issue fixed? I'm still encountering this problem in 7.x-1.5, it shows the error when generating the pdf. I'm using the private file system too. Anyone already solved this ?

TCPDF ERROR: [Image] Unable to get the size of the image: http://example.com/system/files/webform/picture/example.jpg

vegansupreme’s picture

In my experience, check to see if an anonymous user can see the image in question. If not, TCPDF will most likely not be to access it either. I've been using Image Style Access to make whatever image style you want to use for your PDF, viewable to anonymous. There's another module I believe called Private files download permission, but I found that to be somewhat buggy. With that module enabled, I was unable to restore DB backups because of foreign key constraints.

simone960’s picture

You are right, if only anonymous user can see the image will the TCPDF can generate the pdf. I try to change from private file to public file and it works well. But my purpose to use private is to protect my file from anonymous user to access as all images are private and confidential, if I were to expose them to the anonymous user, then no point to set the file system to private.

Besides, since I generate the pdf with admin login, I expect the module knows I have access to the private image file and allow me to generate the pdf. But seems now the issue is not the module itself, I guess that's how TCPDF works. If so, wondering any way to solve this so that TCPDF will generate the pdf as long as the generator has access to the image and not imposing for anonymous access. After all, all libraries files and module are working within the drupal. Hope someone can clarify and assist further. I find this module just awesome. Thanks !

killua99’s picture

@Simon Georges If do you have any kind of solution or want to apply a different approach about this feature please open a new issue with some proposal solution.

To access private file in anonymous use you should use custom modules that allow views PDF to access this files, now I don't remember their names because I've never use them also was long time I hear from them.

No idea if we should include a permission to allow use private files as anonymous users (or run time, some people use cron system to generate the PDFs with private files).

vegansupreme’s picture

@Simone960, When using Image Style Access, you only grant access to a specific style, not the original image. Since Drupal now uses tokens for image styles, it would be nearly impossible to hotlink these images. For my sites, I don't use these special styles anywhere else on the site, so even authorized users wouldn't see these image styles, and couldn't share the link with someone not authorized.
Ideally this module would allow TCPDF to access the filesystem as the current logged in user. I'm not sure how to accomplish this.

qdoscc’s picture

#36 is my preferred workaround