2013-09-25 40 views
3

我有一个在Coldfusion中生成的PDF。我想从另一个PDF文件夹中添加页面。 我检查过cfpdf,但似乎没有办法走。 有没有办法做到这一点?我可以在CFDOCUMENT中包含其他PDF吗?

<cfdocument format="PDF" fontEmbed = "yes" pageType="A4" margintop="0.2" marginbottom="0.1" marginleft="0.2" marginright="0.2"> 
     <cfinclude template="header.inc"> 
     ... content .... 
     pages 2nd PDF should be here 
</cfdocument> 

回答

3

这里最简单的形式是如何将磁盘上的现有PDF附加到动态创建的PDF并将其提供给浏览器,而无需向物理或虚拟文件系统写入任何新内容。

<!--- Create a new PDF and store it in a variable called newPdf ---> 
<cfdocument format="PDF" name="newPdf"> 
    Content of new PDF here. Content of an existing PDF to be appended below. 
</cfdocument> 

<!--- Append to the new PDF the contents of the existing PDF located in the same folder as this script and store it in a variable called mergedPdf ---> 
<cfpdf action="merge" name="mergedPdf"> 
    <cfpdfparam source="newPdf"> 
    <cfpdfparam source="existing.pdf"> 
</cfpdf> 

<!--- Output the merged PDF to the browser ---> 
<cfcontent type="application/pdf" variable="#ToBinary(mergedPdf)#" reset="true"> 

(您可能要添加一个<cfheader>建议如何将PDF应该由浏览器来处理,即inlineattachment。)

+0

经过Adobe CF9.0.1测试 – CfSimplicity

3
+0

我做到了,但在我目前的设置是后生成的PDF文档点击一个链接并立即提供给用户,使用CFPDF它只能保存到磁盘,对不对? – Kokesh

+1

你可以写入内存... http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSe9cbe5cf462523a0-70e2363b121825b20e7-8000.html –

+2

你当然可以在链接请求中,仍然写你的cfdocument pdf理想情况下使用getTempDirectory(),然后使用cfpdf action =“merge”,然后使用cfheader和cfcontent将pdf直接呈现给浏览器。 –

相关问题