質問

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.

役に立ちましたか?

解決

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>

他のヒント

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

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top