TCPDF error: Missing or incorrect image file: http://myserver.net/site/?q=system/files/templateTutorialimages/aFinishe...

The odd thing is: the directory "system/files/ is nowhere in any of the config settings for TCPDF that I can see.

The actual URL of the jpeg is:
http://myserver.net/site/templateTutorialimages/aFinishedModule.jpg

Most of my images have been uploaded with the image module.

The other odd thing is that after hitting the back button from the pdf page (such as http://myserver.net/site/?q=node/190/pdf) to the book page I came from, I always get an error in red at the top of the book page:

warning: getimagesize(http://myserver.net/site/?q=system/files/images/scormMessages.jpg) [function.getimagesize]: failed to open stream: HTTP request failed! HTTP/1.1 403 Forbidden in /home/myserver/public_html/site/modules/pdfview/tcpdf/tcpdf.php on line 3024.

This is a great module otherwise - I hope you can get it working!

Comments

EllenM1-1’s picture

Title: TCPDF error with books that contain images » I got it working but am not sure why

I really have no idea what I am doing, but here is the code I used to replace _pdfview_rewrite_image_url

Perhaps someone can take a look at it and touch it up. It started working when I did this.


/**
 * Ensures that all images are included with absolute paths
 */
function pdfview_check_images($string) {
  return preg_replace_callback('/(?<=src=")(.*?)(?=")/', '_pdfview_rewrite_image_url', $string);
}

function _pdfview_rewrite_image_url($matches = array()) {
  $path = $matches[0];
  if (strstr($path, 'http://')) {
    return $path;
  }
  
  else {
 
        $path = str_replace(' ', $path);
      }
  
    return file_create_url($path);
}
Egon Bianchet’s picture

Title: I got it working but am not sure why » Rewrite image urls to make them absolute

Yes, that's the code in question: it tries to rewrite image urls to make them absolute, because tcpdf won't work otherwhise. The problem is that it should work with sites with private downloads enabled as well as with those with public downloads ...

Egon Bianchet’s picture

Status: Active » Closed (duplicate)

marking it duplicate of http://drupal.org/project/comments/add/76415, it's the same issue

EllenM1-1’s picture

Thanks!