ColdFusion Muse

You CAN Use the File System With Cfdocument (Who Knew)

In regard to my previous post on Cfdocument and SSL I stand corrected. It is definitely possible to use a "file:" protocol identifier in the image path when using Cfdocument. My problem was with the syntax. As is often the case, a helpful reader put me on the right path. Thanks to Julian Halliwell for pointing out that my problem was syntax. I was trying 2 slashes as in:

<img src="file://d:\mysite\images\myimage.jpg" width="50" height="60">
Julian noted that it should actually be 3 leading slashes after the "file:" protocol identifier.
<img src="file:///d:\mysite\images\myimage.jpg" width="50" height="60">

Not only is this a rock solid fix for the SSL issue (see the previous post) but it has the potential to dramatically impact the speed of your cfdocument call, especially if you using large images. We have an application that embeds fairly large photographic images. I'm guessing this will greatly increase the speed of rendering. I'll post a follow up and let you know.

Related Blog Entries

Comments
Steve's Gravatar How much success did you have when trying to load large JPEGs into a PDF via cfdocument?

I am having time out issues - but strangely enough, if I use GIFs it loads no problem. Obviously I can't just use GIFs to display photos in a PDF so I am still searching for a solution..
# Posted By Steve | 12/6/06 5:15 PM
federico's Gravatar THANKS VERY MUCH!!!!
# Posted By federico | 2/27/08 11:37 AM
Kate's Gravatar I'm using src="file://E:\Inetpub\wwwroot\portal\logo_30.jpg" and when viewing this outside cfdocument (haven't gotten to the inside yet) I get a broken image in Firefox. Not the red x, but more like the IE compatibility mode icon.
# Posted By Kate | 10/26/10 5:52 PM
R Waits's Gravatar This solution worked great for PDFs, but I was hoping it would also work for Word docs. I cannot get it to work, any ideas?
# Posted By R Waits | 1/27/11 6:13 PM
R Waits's Gravatar just to be clear, I am trying to create a word doc using the usual cfheader and cfcontent tags.
# Posted By R Waits | 1/27/11 6:30 PM
Mark Kruger's Gravatar @R Waits,

Ok... cfdocument pulls these resources in (from the file system or using http) and then embeds them as BINARY objects in the file format. To do this for word / cfcontent - you will need to produce the equivilent binary representation that WORD expects. Remember - a document (like word or PDF) is self contained and off line - it has to contain everything it needs for the rendering engine to work. If you look at a .docx document with embedded images (for example) you will see what is probably binary or ... maybe base64 encoded values where the image is embedded. This will require some research. it may be possible using native CF like toBase64().. it's almost certainly possible using Java. But you likely have some long nights of trial and error ahead of you to do it.

-Markj
# Posted By Mark Kruger | 1/27/11 6:49 PM



Blog provided and hosted by CF Webtools. Blog Sofware by Ray Camden.