12 Oct 2011

Missing image in PDF formatted cfm pages

Image was missing in PDF formatted cfm pages after we start to use https.
Red x box appeared on the pages, and loading time was horrible.
I used the function below to use java.io.File class instead of http request to get the image.

<cffunction name="localUrl" >
  <cfargument name="file" />
  <cfset var fpath = ExpandPath(file)>
  <cfset var f="">
  <cfset f = createObject("java", "java.io.File")>
  <cfset f.init(fpath)>
  <cfreturn f.toUrl().toString()>
</cffunction>

In the Coldfusion pages, you can use the function like this.

<img border = "0"
    src = "#LocalURL("../css/Images/#theImage#")#"
    width = "#thisImageWidth#px"
    height = "#thisImageHeight#px" />

0 comments:

Post a Comment