Reputation: 16139
We have PDF's which include standard PDF forms. We would like to merge them and fill data into the fields at the same time.
The problem is that sometimes we may merge the same document more than ones into the final document.
Is there a way to rename the the fields (Attach __#) in the PDF so that the repeated documents do not conflict?
I can do this with iText code, I'm testing the CFPDF/CFPDFFORM code to get rid of iText.
Upvotes: 2
Views: 739
Reputation: 3308
You cannot rename the fields with cfpdf or cfpdfform. You can get around the problem by populating and flattening each form before you merge them.
Here's a simplified example:
<!--- 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)#">
Upvotes: 1