I have seen huge no of postings on CF forum where CFDocument users have complained about seeing red-cross (or red-x ) for images . In this post, I would like to list the reasons why they happen and how they could be resolved .
Before we proceed with different cases of red-x, lets see in brief, how images are rendered in CFDocument.
Now lets see different scenarios one by one
- Image name has space in it. In CFMX 7.0, you can get red-x for images if the image file name has any space in it. For example if the image file name is “my picture.jpg”, only a red-x will appear in the pdf/flashpaper. It happens because the url created for the image is not encoded. A workaround for this is to either use encoded url for the images i.e replace ‘space’ in the name with ‘%20‘ OR dont have spaces in the file name at all . This bug has been fixed in Merrimack (Coldfusion 7.0.1). So if you are still on 7.0, upgrade
- If your server is behind firewall. As we mentioned earlier, CF server needs to send an HTTP request for the images. If the firewall prevents any outgoing connection from the server, CF will not be able to retrieve them and will show a red-x in place of them. You will need to setup your firewall in such a way that server can send an HTTP request to itself.
- If your server is behind a proxy. If Coldfusion server is connected to the external world using a proxy, then also CFDocument will not be able to load the images. This is because currently there is no way you can specify proxy configuration for CFDocument tag.
Current solution to solve this is to define the following system properties for the JVM. You can specify these in “runtime/bin/jvm.config” if you are using standlone or on JRun server.
-DproxySet=true -DproxyHost=[hostname] -DproxyPort=[port] -Dhttp.proxyHost=[hostname] -Dhttp.proxyPort=[port]
- If you are using HTTPS and your images do not appear in the pdf/flashpaper, you must ensure the following
- CF server’s certificate is trusted. In other words, certificate of the CA who issued the certificate for you, must be present in the trusted certificate store (runtime/lib/trustStore). You can use keytool to list/view/import/.. certificate in the certificate store.
If CF is using a self signed certificate, CF’s certificate must be present in the trustStore.
- The certificate is valid and has not expired.
- Host name of the server must match the host name to which the certificate was issued.
See this entry for more details on this workaround. The other solution is to write little java code to set a ‘java.net.Authenticator‘. I will post a separate entry for this.
You can give any name here as userAgent in place of “ColdFusion”.
Hope this helps people in resolving isues related to missing images in CFDocument. In case you are getting a red-x even after verifying all the cases mentioned above, please let me know.
Related Entry :