Hi there i spent the last hours to find out that the reason why my images are not showing anymore is, that the ?itok value (came with 7.20)is not covered by the reg ex in _print_pdf_file_access_images.
domPDF is not rendering images via local file access when there is an ?itok... after it.

Best Regards
Lars

P.S.: Ah and one more thing: dompdf is not able to see a picture as a local picture, when the src begins with http://

Comments

jcnventura’s picture

Status: Active » Closed (duplicate)
ey’s picture

Version: 7.x-1.2 » 7.x-1.x-dev
Issue summary: View changes
Status: Closed (duplicate) » Needs work

It is not the duplicate of the mentioned issue, since the versions are different. This issue was about 7.x-1.2, I'm updating it to 7.x-1.x-dev and reopen the issue, since the problem still exists on 7.x-1.x branch.

Please port the fix to this branch as well, so that we can close this issue.
Thanks.

ey’s picture

Title: dompdf: images not found because itok » Images not found because of itok
Assigned: Unassigned » ey
Priority: Normal » Major
Status: Needs work » Needs review
StatusFileSize
new1.06 KB

I've created a patch which solves the issue. I've modified the regex to omit the itok.

Please review.

ey’s picture

Title: Images not found because of itok » Dompdf: Images not found because of itok
ice70’s picture

Hi,

I applied this patch and I can see the itok in the regex, but the itok querystring is still in the local image string and shows up as a missing image on the pdf.

Any guidance would be greatly appreciated.

Thank you
ice70

Johnny vd Laar’s picture

StatusFileSize
new1.38 KB

I've modified the patch such that it also works for 7.x-2.x. The pattern is a bit different because the itok part is optional.

Johnny vd Laar’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
ey’s picture

Version: 7.x-2.x-dev » 7.x-1.x-dev

@Johnny vd Laar: This issue is for 7.x-1.x. Please check #1926982: preg_replace pattern for 7.x-2.x.

hwasem’s picture

Ice70, I'm having the same problem after applying the patch in #2. Did you ever find a successful resolution for version 7.x-1.3?

Thanks,
Heidi

ice70’s picture

Hi Heidi,

sorry it has been a while since I did this and the project I think I did it for has long since moved to a different developer.

But, I *think* I got it working by adding:
$conf['image_allow_insecure_derivatives'] = TRUE;
to: settings.php

hope this helps :s

ice70

gaborpeter’s picture

StatusFileSize
new1.4 KB

The path worked for me, but not for all cases.
The pattern says \w which not matching all itoks, as they may contain "-" character. (Check the function which generated the itok image_style_path_token + drupal_hmac_base64)

Thus the \w has to be replaced with [a-zA-Z0-9\-]

New patch attached.

kyberman’s picture

Thank you gaborpeter, this works well. But there is also underscore as possible character (I had "itok=m_eKzA05"), so "[a-zA-Z0-9\-_]" worked for me. Please, add "_" to your patch.

Anonymous’s picture

Updated patch as in comment #12 fixes the problem for me too. Thanks a lot gaborpeter and kyberman.

mschudders’s picture

mschudders’s picture

I have updated the patch.

This is working for me on DomPDF with the latest DEV version of print.

What I needed to do was:

on this page: "/admin/config/user-interface/print/pdf".

check this checkbox Access images via local file access
Enabling this option will make the tool use local file access for image files. This option is not recommended to use in conjunction with modules like imagecache which generate the image after it's first accessed. However, it may be necessary in low-end hosting services where the web server is not allowed to open URLs and the user can't modify that configuration setting.

Otherwise it wouldn't work.

retiredpro’s picture

I'm on 7.x-2.x-dev and I applied the patch from #14 and checked the box for "Access images via local file access" as mentioned in #15. Fixed the issue for me. Thanks!

I was initially confused because the issue currently states that this is for 7.x-1.x-dev but the last few patches are targeting /includes/print.inc which 1.x does not have.

skdrupal88’s picture

#14 works well, thanks Mschudders

  • jcnventura committed 9cb026d on 7.x-2.x authored by Mschudders
    Issue #1948414 by Елин Й., Mschudders, Johnny vd Laar, gaborpeter:...
jcnventura’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Status: Needs review » Fixed

Thanks everyone!

Status: Fixed » Closed (fixed)

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