DocRaptor is able to load the CSS but cannot load images. Here are 2 examples from the log.

msg|inf||loading image: /home/my_domain/public_html/my_domain.com/sites/default/files/images/slide1.jpg
msg|wrn|/home/my_domain/public_html/my_domain.com/sites/default/files/images/slide1.jpg|can't open input file: No such file or directory

msg|inf||loading image: /home/my_domain/public_html/my_domain.com/misc/watchdog-warning.png
msg|wrn|/home/my_domain/public_html/my_domain.com/misc/watchdog-warning.png|can't open input file: No such file or directory

Wondering why the URL isn't absolute i.e. http://my_domain.com/sites/default/files/images/slide1.jpg

Comments

apmsooner’s picture

Sounds more like a configuration issue on how files are being rendered on the node. You might try hardcoding the img tag in the body of the node and see if docraptor takes it. Might also check the view mode for the print display to see how the image is rendering... ie; try original image instead of cached style since that styled image might not exist until the node has saved and image is viewed.

bisonbleu’s picture

Hum...

I'm using the Insert module on the Basic Page content type.

In the insert settings, I've checked the option Use absolute paths. The HTML source of the printer-friendly page shows a correct absolute URL to the original image (no style) http://my_domain.com/sites/default/files/images/diapositive1.jpg. I can load this image when I paste this URL in my browser. But DocRaptor says No such file or directory.

I've tried unchecking Use absolute paths. The HTML source of the printer-friendly page shows a correct relative URL /sites/default/files/images/diapositive1.jpg. But DocRaptor says No such file or directory.

Resetting to Use absolute paths.

If I revert the Print settings to use mPDF instead of Docraptor. The image is included in the PDF.

I've also enabled and configured the Print view mode for Basic Page. But DocRaptor says No such file or directory.

My website is running from a subfolder. So in settings.php, I've set $base_url = 'http://my_domain.com'; but nothing changes.

Darn... where's my T-Rex laser gun! ;-)

update 1: Tested on a different server where Drupal is installed in 'public_html' but where images are stored in private://images. Same problem: No such file or directory.

update 2: Tested on yet another server where Drupal is installed in 'public_html' but where images are stored in public://images. Works like a charm!

So it appears that my issue is related to the fact that my website is private (and needs to be): users are required to log in and all medias & files are stored using Drupal's Private file system path.

So the question becomes can docraptor_pdf_library be used for private websites?

apmsooner’s picture

Anything you want a third party interface to have access to needs to be publicly accessible so... no if your files are in private folder, docraptor will not be able to access them.

apmsooner’s picture

Status: Active » Closed (works as designed)
bisonbleu’s picture

Component: Code » Documentation
Category: Bug report » Support request
Status: Closed (works as designed) » Active

Reopening and changing category and component to Support request/Documentation (i.e. not a bug).

Anything you want a third party interface to have access to needs to be publicly accessible...

Yes and no. I can see at least one option that would work when using Drupal's private file system is a must: replacing images with inline data URI. These data URI can be directly inserted in the HTML; that works for sensitive files.

They can also be loaded in CSS; that's ok for not so sensitive files such as icons.

The most interesting page I found on Drupal is Data URI Creator's project page. Lots of information worth reading.

Cheers!

apmsooner’s picture

Cool, please try that out and report back how it works out.

bisonbleu’s picture

So if anybody is interested, it is possible to send images stored in Drupal's private file system to an external service such as DocRaptor using Image Base64 Formatter.

  • Install & enable image_base64
  • in Manage display, make sure your image field uses the new Base64 encoded format
  • in the settings (gear icon), check Wrap in an image tag

That's it. Works great with DocRaptor PDF Library : )

For more flexibility, consider creating a field collection with unlimited values made up of a Long text and an Image field. Then add items as required.

apmsooner’s picture

Status: Active » Closed (works as designed)