1

At the moment I am converting the data on the page to PDF this way:

<cfdocument format="PDF">
  <cfoutput>
    #pageContent#
  </cfoutput>
</cfdocument>

With #pageContent# being a variable created using cfsavecontent

The way it works is that I have a 'Export to PDF' link at the bottom of the page which contains a url variable - this link directs to the same page but the variable passed in tells it to output the PDF.

My question is, when the link is clicked to create the PDF, is there a way to upload the PDF to the database at the same time?

I know I have to use cffile action="Upload" and similar, but I'm not sure how to tell the page when a PDF has been opened.

Hope this makes sense.

4

1 回答 1

3

您可以使用filename属性cfdocument将文件直接保存到您选择的位置的服务器中。 CFdocument 文档。您还可以查看使用CFPDF

文件名-可选- 包含 PDF 或 FlashPaper 输出的文件的路径名。如果省略文件名属性,ColdFusion 会在浏览器中显示输出。

<cfdocument filename = "c:/~" ...> <!--- filename attribute to save to server --->
   #pageContent#
</cfdocument>

<cfquery ...>
    <!--- sql --->
</cfquery>

<!--- once your document is saved and database updated--->
<cflocation url = "[your saved file].pdf"...>
<!--- or as Peter Suggested --->
<cfcontent type="application/pdf" file="[your saved file].pdf">
于 2013-03-01T14:50:20.523 回答