Skip to main content
ilssac
Inspiring
June 3, 2011
Question

Merge data and flaten a PDF form.

  • June 3, 2011
  • 1 reply
  • 2145 views

I am working for the first time on using ColdFusion to populate PDF forms.

I have a simple PDF form I created with my Acrobat 9 Pro tool.  Using the following code, pretty much straight from the documentation, I can easily populate the fields in the PDF with data and save a new PDF file with that data.

<cfpdfform
    source="#getDirectoryFromPath(getCurrentTemplatePath())#QP-ExpiringLetter.pdf"
    destination="#getDirectoryFromPath(getCurrentTemplatePath())#test.pdf"
    action="populate">
    <cfpdfformparam name="bus_name" value="123 PEST CONTROL">
    <cfpdfformparam name="bus_address" value="1234 MAIN STREET">
    <cfpdfformparam name="bus_city_state_zip" value="HOMETOWN, CA  98765">
</cfpdfform>

But the file is still a "Form" file with the fields editable.  I do not want this.  I want a static PDF file with the fields filled in with the data I provided.  Looking at the documentation, it seems the <CFPDF...> tag has functionality to flatten such form files and do what I want.  What I can not find documentation for, or guess at, is HOW to combine these two tags.  I know I could work with a PDF variable in the <CFPDF...> tag, but I see no way to capture the output of the <CFPDFFORM...> tag into such a variable, I can only send the output to the browser or a file.

Is that the only way to do this?  Send the output to a file, then read that file with the <CFPDF...> tag to flatten it to another file?  That seems a bit IO overhead heavy for what I feel should be able to be done in memory with just one file write.

TIA

Ian

This topic has been closed for replies.

1 reply

Inspiring
June 3, 2011

I thibk the overhead isn't too bad with the memory filesystem. But you could also use DDX directly.

ilssac
ilssacAuthor
Inspiring
June 3, 2011

Ok, so now I just need to ALSO learn how to use a memory file system AND|OR DDX.  Two other features of which I am aware, but have never used before.  Off to the documentation I go again.