我在cfdocument中显示图像时遇到问题。我已经尝试了几个不同的选项,但没有成功(请参阅下面的测试代码)。
cfdocument似乎识别出有一个图像文件,因为表单元格的大小发生了变化。然而,它仍然不显示图像的内容。如果有任何帮助,我将不胜感激。
<cfdocument format="PDF" localURL = "yes">
<p style="background-color:#006633">
<table border="1">
<tr><td><cfoutput>
output from "file:///#ExpandPath('CEUCertificate_ABondy3.jpg')#"
</cfoutput>
</td>
<td style="background-color:white">
<cfoutput>
<image src="file:///#ExpandPath('CEUCertificate_ABondy3.jpg')#">
</cfoutput>
</td>
</tr>
<tr><td><cfoutput> output from #ExpandPath('CEUCertificate_ABondy3.jpg')# </cfoutput> </td>
<td>
<cfoutput>
<image src="#ExpandPath('CEUCertificate_ABondy3.jpg')#">
</cfoutput>
</td>
</tr>
<tr><td style="background-color:red">
Output from: img src="CEUCertificate_ABondy3.jpg"
</td>
<td style="background-color:red">
<img src="CEUCertificate_ABondy3.jpg"/>
</td>
</tr>
<tr>
<td style="background-color:white">
output from image src="CEUCertificate_ABondy3.jpg"
</td>
<td>
<cfoutput>
<image src="CEUCertificate_ABondy3.jpg">
</cfoutput>
</tr>
<tr>
<td>Output from local url</td>
<td>
<cfoutput>
<img src=#localUrl("CEUCertificate_ABondy3.jpg")#>
</cfoutput>
</td>
</tr>
</table>
</p>
</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>发布于 2013-05-15 04:20:36
对于最初的问题,您需要像引用任何其他cfdocument页面一样在HTML标记中引用图像;<img src="url-to-the-image" />。所以这对你来说应该是可行的。
<img src="/cde/mobileweb/CEUCertificate_ABondy3.jpg"/>现在您已经进行了更改,页面将超时。这可能是由于图像的创建方式造成的。See this page here。这是我从Charlie's page here那里找到的。
尝试在编辑器中打开该图像,然后重新保存。然后看看处理时间是否减少了。
我在Ben Nadel's blog here上找到了更多关于这方面的讨论。
发布于 2013-05-15 03:58:54
不要把ExpandPath()和file://搞得乱七八糟,把它编码成一个普通的html,并确保它首先能正常工作。然后在<cfdocument>中使用localUrl="true"
https://stackoverflow.com/questions/16551390
复制相似问题