这里最简单的形式是如何将磁盘上的现有 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
。)