我在Coldfusion中生成了一个PDF。我想添加来自文件夹中的另一个PDF的页面。 我已经检查了cfpdf,但它似乎不是要走的路。 有没有办法做到这一点?
<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>
答案 0 :(得分:3)
答案 1 :(得分: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,即inline
或attachment
。)