简体   繁体   English

我可以在CFDOCUMENT中包含另一个PDF吗?

[英]Can I include another PDF in CFDOCUMENT?

I have a PDF generated in Coldfusion. 我在Coldfusion中生成了一个PDF。 I would like to add pages from another PDF sitting in the folder. 我想添加来自文件夹中的另一个PDF的页面。 I've checked cfpdf, but it doesn't seem to be the way to go. 我已经检查了cfpdf,但它似乎不是要走的路。 Is there a way to do this? 有没有办法做到这一点?

<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>

Here in its simplest form is how to append an existing PDF on disk to a dynamically created PDF and serve it to the browser without writing anything new to the physical or virtual file system. 最简单的形式是如何将磁盘上的现有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">

(You might want to add a <cfheader> to suggest how the PDF should be handled by the browser, ie inline or attachment .) (您可能需要添加<cfheader>来建议浏览器应如何处理PDF,即inlineattachment 。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM