动态pdf-cfdocument + cfcontent + image +电子邮件附件 [英] dynamic pdf-cfdocument + cfcontent + image + email attachement

查看:209
本文介绍了动态pdf-cfdocument + cfcontent + image +电子邮件附件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将图像加载到动态生成的pdf(cfdocument)中?因为pdf不存储hdd。 pdf需要通过电子邮件发送,并且ram清除。图像存储在wwwroot文件夹之外。
如果需要,pdf可以存储在hdd中,附加,通过电子邮件发送,然后删除,但会选择不存储在hdd。

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:\coldFusion9\imgs\是dir

c:\coldFusion9\imgs\ is the dir

示例:

<cfdocument format="PDF" localurl="true">
<cfoutput> #vars#</cfoutput>
</cfdocument>

我使用了

<img src="">

,如果图像在wwwroot(http ...)但不是当映像位于外部的wwwroot(c:\coldFusion9\imgs#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:\coldFusion9\imgs#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:\coldFusion9\imgs\#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在屏幕上呈现,以知道图像是否被加载。

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.将图像放在cfdocument中
3.将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:\temp\test.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 + image +电子邮件附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆