In ColdFusion, can I rename a PDF form field with CFPDF?

We have a PDF that includes standard PDF forms. We would like to combine them and fill the data in the fields at the same time.

The problem is that sometimes we can combine the same document in more than a final document.

Is there a way to rename the (Attach __ #) fields in PDF so that duplicate documents don't clash?

I can do it with iText code, I am testing CFPDF / CFPDFFORM code to get rid of iText.

+2


source to share


1 answer


You cannot rename fields with cfpdf or cfpdfform. You can work around the problem by filling and flattening each shape before combining 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)#">

      

+1


source







All Articles