ColdFusion: trying to create dynamic downloadable PDF, but not create a file?

落花浮王杯 提交于 2019-12-11 05:42:38

问题


I haven't been able to find an answer to this ColdFusion/PDF question so here goes:

I already have a back-end that creates dynamic PDFs using CFDOCUMENT. The user has to submit payment first via authorize.net, then once the payment is processed, they click a link to download a dynamic PDF we create.

The PDF is saved in a file on our server. The link the user clicks to download it calls CFHEADER and CFCONTENT which points to the PDF location on the server and it downloads for them.

However, I don't want to store the PDFs on the server anymore if I don't have to. I'd like them to be able to click the link to download, then have the PDF be generated dynamically, be available for download, but not saved on the server.

Is this possible? Or do you have to create a file for them first if they want to download a dynamically created PDF?


回答1:


Here is how I do it on a test page I have in version 9.

<cfdocument format="pdf">
Hello.  This is a very simple pdf file.
</cfdocument>

It is called by this anchor tag.

<a href="pdf_output.cfm" target="_blank">
Click here to open new tab/window with pdf content that is generated at runtime.
</a>



回答2:


Your link can send them to a page with something like this, where #thePDF# contains a binary object created from <cfdocument name="thePDF" ...>:

<cfheader name="content-disposition" value="attachment; filename=mypdf.pdf"/>
<cfcontent type="application/pdf" variable="#thePDF#" />


来源:https://stackoverflow.com/questions/46066873/coldfusion-trying-to-create-dynamic-downloadable-pdf-but-not-create-a-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!