我正在使用 cfcontent 从网络根目录外部流式传输图像。虽然在浏览器中直接调用各个页面时图像可以正确显示,但图像在生成的 pdf 中显示一个红色 X。在导出页面上:
<cfsavecontent variable = "gridCode">
<cfinclude template="pathToGeneratedPage.cfm" >
</cfsavecontent>
<cfdocument format="pdf" filename="#filename#" overwrite="yes" localUrl="yes">
<cfdocumentsection >
<cfoutput>#gridCode#</cfoutput>
</cfdocumentsection>
</cfdocument>
在需要生成内容的页面上:
<img src="pathToDisplayPhoto.cfm?image=#someImage#" />
在displayPhoto.cfm页面上:
<cfcontent type="image/*" file="#pathToUploadFolderOutsideWebRoot##url.image#" deleteFile = "No">
我包含了 cfdocument 属性 localUrl="yes"因为默认值(no)不起作用。明确设置为“否”也不起作用。
有什么建议吗?
最佳答案
我正在保存创建的 pdf,发现 localUrl="yes"
(或 =true
)失败。
<img src="file:\\\#replace(getCurrentTemplatePath(),"my.cfm")#images\my.png">
为任何在桶底寻找想法的人工作。 getCurrentTemplatePath() 获取文件名和路径,所以我必须删除它(因此替换(...,“my.cfm”)。我也尝试过 ExpandPath(“.”),但也失败了。
关于image - 无法使用 cfdocument/cfcontent 在 pdf 中包含图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11969692/