I am getting the following exception when using print_pdf and TCPDF 5.9.202 and 5.9.120 (I needed to hack print_pdf.pages.inc with some error reporting to see it):

ImagickException Object
(
    [message:protected] => unable to open file `/home/.../www/.../drupal-7.x/file:/home/.../www/.../drupal-7.x/sites/default/files/logo2013-2-64_0.png' @ png.c/ReadPNGImage/2921
    [string:private] => 
    [code:protected] => 1
    [file:protected] => /home/.../www/.../drupal-7.x/sites/all/libraries/tcpdf-5.9.120/tcpdf.php
    [line:protected] => 8109
    [trace:private] => Array
        (
            [0] => Array
                (
                    [file] => /home/.../www/.../drupal-7.x/sites/all/libraries/tcpdf-5.9.120/tcpdf.php
                    [line] => 8109
                    [function] => readimage
                    [class] => Imagick
                    [type] => ->
                    [args] => Array
                        (
                            [0] => file:///home/.../www/.../drupal-7.x/sites/default/files/logo2013-2-64_0.png
                        )



Reviewing the code, I see that _print_pdf_file_access_images() converts all private images to "file://" streamwrapper. While TCPDF itself seems to handle those OK, TCPDF calls Imagick and passes file names directly (i.e. $img = new Imagick(); $img->readImage($file);). Imagick is not handling streamwrapper file names and throws the above exception.

Comments

iva2k’s picture

Status: Active » Needs review
StatusFileSize
new6.05 KB

In case anyone is interested, here's a patch that includes:

  1. TCPDF class error reporting pass-through
  2. TCPDF catch exceptions and log to watchdog
  3. TCPDF remove stramwrappers for Imagick compatibility
  4. TCPDF Fixed last slash in K_PATH_CACHE
yang_yi_cn’s picture

I'm definitely interested, having the same problem for the 6.x version as well.

I believe the 6.x version doesn't use streamwrapper. However I do have a question is that why the TCPDF try to use ImageMagick at all? Although it is available, my image API toolkit is set to use GD.

yang_yi_cn’s picture

Title: TCPDF chokes on private images » TCPDF chokes on imagemagick
Version: 7.x-1.2 » 6.x-1.18
StatusFileSize
new1.17 KB

This issue is more related to the image extension (GD v.s. ImageMagick) as this issue happens to public file system as well.

Also, attached a patch for 6.x

yang_yi_cn’s picture

Issue summary: View changes

cleanup

jcnventura’s picture

Status: Needs review » Closed (outdated)

Closing all issues related to the Drupal 6 version of the print module.