Images not displaying in CFDOCUMENT PDF

When creating a PDF which contains images I found that it worked in my development envirmonet but would not work in the production environment. The only difference was that the production environment had an SSL. Rightly so the SSL was causing the issue and so the PDF would display a small box with a red cross.

To get round this there are a couple of ways. You can ensure that your certificated is added to the trusted certificate store (runtime/lib/trustedStore). You can use keytool to list/view/import… certificate in the certificate store. This can get pretty involved if you are not familar with what you are doing. The other method is very simple and a quick change to the code, it uses the file protocol identifier in the image path and you will find it works a treat!

This is how we insert an image using HTML:

<img scr="https://www.mydomain.com/images/myimage.jpg" width="60px" height="60px">

When creating a PDF where the site has an SSL you simply do the following:

<img scr="file:///d:\mysite\images\myimage.jpg" width="60px" height="60px">

It is a simple as that and it’s a very quick fix and will save you time.

Leave a Reply

Your email address will not be published. Required fields are marked *