我们有PDF的,其中包括标准的PDF表单。我们希望将它们合并,同时将数据填充到字段中。
问题是,有时我们可能会将同一文档合并到最终文档中,而不是合并到最终文档中。
有没有办法重命名PDF中的字段(Attach __#),使重复的文档不冲突?
我可以用iText代码做到这一点,我正在测试CFPDF/CFPDFFORM代码以摆脱iText。
发布于 2009-11-25 05:28:05
不能使用cfpdf或cfpdfform重命名字段。在合并表单之前,您可以通过填充和展平每个表单来解决此问题。
下面是一个简化的例子:
<!--- populate each form --->
<cfloop from="1" to="#arrayLen(files)#" index="i">
<cfset destination = "#i#.pdf" />
<!--- fill in form fields --->
<cfpdfform
action = "populate"
source = "#pdf_source_file#"
destination = "#destination#"
>
<!--- form params here --->
</cfpdfform>
<!--- flatten file --->
<cfpdf
action = "write"
source = "#destination#"
destination = "#destination#"
flatten = "yes"
/>
</cfloop>
<!--- merge flattened files --->
<cfpdf action="merge" name="output">
<cfloop from="1" to="#arrayLen(files)#" index="i">
<cfpdfparam source="#i#.pdf">
</cfloop>
</cfpdf>
<!--- return the full pdf --->
<cfcontent type="application/pdf" reset="true" variable="#toBinary(output)#">https://stackoverflow.com/questions/1590007
复制相似问题