动态 pdf-cfdocument + cfcontent + 图片 + 电子邮件附件 [英] dynamic pdf-cfdocument + cfcontent + image + email attachement
问题描述
如何将图像加载到动态生成的 pdf (cfdocument) 中?因为pdf没有存储在硬盘中.pdf需要通过电子邮件发送,并清除内存.图像存储在 wwwroot 文件夹之外.如果需要,可以将 pdf 存储在硬盘中、附加附件、通过电子邮件发送,然后删除,但会选择不存储在硬盘中.
How can images be loaded into a dynamically generated pdf (cfdocument)? In that the pdf is not stored the hdd. The pdf needs to be emailed, and the ram cleared. The images are stored outside of the wwwroot folder. If it is need be, the pdf can get stored in the hdd, get attached, emailed, then deleted, but would opt for it not to get stored in the hdd.
c:coldFusion9imgs 是目录
c:coldFusion9imgs is the dir
示例:
<cfdocument format="PDF" localurl="true">
<cfoutput> #vars#</cfoutput>
</cfdocument>
我用过
<img src="">
在 cfdocument 中,如果图像位于 wwwroot (http...) 文件夹中,则它可以工作,但当图像位于 wwwroot 之外时(c:coldFusion9imgs#image#.png"或../imgs/#image#.png").
inside cfdocument, and it works if the image is in the wwwroot (http...) folder, but not when the image is outsite the wwwroot ("c:coldFusion9imgs#image#.png" or "../imgs/#image#.png").
我认为 cfcontent 是理想的
I suppose that cfcontent is ideal
所以,在 cfdocument 中,我这样做:
So, inside cfdocument, I do this:
<cffile action="readbinary" file="c:coldFusion9imgs#image#.png" variable="img">
<cfcontent type="image/jpg" variable="#img#" >
结果是图像加载到屏幕上,而不是 pdf.
The result is that the image loads, on the screen, not the pdf.
希望将 pdf 作为电子邮件附件通过电子邮件发送.pdf 不需要在屏幕上呈现,但出于测试目的,我们可以通过命名或不命名 cfdocument 来让它呈现在屏幕上以了解图像是否已加载.pdf 会在名称被移除时呈现,当名称存在时不会呈现.
Would like to email the pdf as an email attachement. The pdf does not need to render on screen, but for testing purposes, we could let it render on the screen to know if the image was loaded or not, by either naming or not naming the cfdocument. The pdf renders when the name is removed, it does not render when the name is present.
感谢您的帮助.
推荐答案
如果我理解你的问题.你想要1. 从您的 webroot 之外的文件夹中获取图像2. 将图片放入cfdocument3. 将 cfdocument 附加到 cfmail
If i understand your question correctly. You want to 1. Grab an image from a folder outside of your webroot 2. Place image in a cfdocument 3. Attach cfdocument to a cfmail
如果是这种情况,您需要 cfimage 而不是 img,其余的可以在 Ben Nadel 的网站上找到 http://www.bennadel.com/blog/1700-Ask-Ben-Creating-A-PDF-And-Attaching-It-To-An-Email-Using-ColdFusion.htm
if that's is the case you need cfimage instead of img and the rest you can find on Ben Nadel's site http://www.bennadel.com/blog/1700-Ask-Ben-Creating-A-PDF-And-Attaching-It-To-An-Email-Using-ColdFusion.htm
或展开下面的片段.
<cfdocument format="pdf" name="mydoc">
<cfimage action="writeTobrowser" source="c: emp est.png" >
</cfdocument>
<cfmail
from="x@y.com"
to="y@x.com"
subject="this is it">
<cfmailparam
file="mydoc.pdf"
type="application/pdf"
content="#mydoc#"/>
</cfmail>
这篇关于动态 pdf-cfdocument + cfcontent + 图片 + 电子邮件附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!