问题
I found a curios situation couple of days back which I was able to solve after losing a lot of temper.
Well the issue is I am placing an image inside a dynamically created pdf(using cfdocument). I am able to see the image when I run my website locally. But once I upload the code to prod I get the broken-image at the image placeholder.
回答1:
accepting Al everett's suggestion, the solution to problem is briefed. The issue of the image not being displayed was due to the HTTPS access of the document and images was not being downloaded. so I used the below work around:
<cfdocument format="pdf">
<cfoutput>
Some html content
<br>
<img src=#localUrl("img1.gif")#><br>
<img src=#localUrl("images/img.jpg")#>
</cfoutput>
</cfdocument>
<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>
回答2:
This is usually caused by internal path versus external path. You are likely referencing a domain in the URL which may not be valid internally. One solution is to update your server's host file to include all valid domains and their internal network IP equivalents. Then when the domain is requested on the server, the internal IP is referenced instead of invalid external IP.
http://www.google.com/search?q=host+file+internal+domain
来源:https://stackoverflow.com/questions/6109183/image-not-displayed-in-cfdocument