问题描述
我几天后发现了一个好奇的情况,我在失去了很多脾气之后能够解决这个问题。
I found a curios situation couple of days back which I was able to solve after losing a lot of temper.
问题是我将图像放在动态创建的pdf中(使用cfdocument)。当我在本地运行我的网站时,我能够看到图像。但是,一旦我将代码上传到prod,我就会在图像占位符处获得损坏的图像。
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.
推荐答案
接受Al everett的建议,简要解决了问题。未显示图像的问题是由于文档的HTTPS访问和未下载的图像。所以我使用了下面的工作:
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>
这篇关于图像未显示在cfdocument中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!