Ask a Jedi/Stump the Chump: CFDOCUMENT PDFs with Forms

This post is more than 2 years old.

Jay asks:

I am tryin gto add a button, specifically an email button, to pdf created in CF8. I am not sure how to do this. I thought in CF8 you could create a pdf with CFDocument and in this process add buttons to do whatever. Is this possible? If so how?

I marked this both as a "Ask a Jedi" and "Stump the Chump" because I'm not sure I have the exact right answer. I believe the answer is no though. From what I know - CF8 does let you work with PDF forms that were created in Acrobat/LiveCycle. So it can handle existing forms. It can even put an existing PDF Form inside a PDF made with CFDOCUMENT. But you can't create an interactive form from scratch with CFDOCUMENT.

Now - if you want to get a bit down and dirty - you can use iText. They have a tutorial on creating interactive forms. For an excellent set of examples of using iText in ColdFusion, check out the iText category over at cfSearching.

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA https://www.raymondcamden.com

Archived Comments

Comment 1 by david buhler posted on 1/25/2008 at 11:32 PM

Does he mean:

"I want to add a mailto:joe@johndoe.com link within my PDF?"

That, you could probably do with an 'a href' link?

Comment 2 by C.Gratz posted on 1/25/2008 at 11:35 PM

David,

I am guesses he means a button to email the form contents to a specific address after they are filled out. I am agreeing with Ray, that out of the box, I don't think CF does this without iText integration.

Comment 3 by Roland Lopez posted on 1/26/2008 at 12:25 AM

You're right, Ray, this can not be achieved with ColdFusion. CF does not have the capability to create dynamic PDF forms. The cfform reference page for CF8, states that you can but that is actually incorrect.

You can easily achieve this using the LiveCycle Designer and it will attach the XML data from the Form using your email application. Then you can take the XML to populate a blank copy of the PDF form. If you want to send the whole PDF document, however, you need to first "bless" it with the Reader Extensions. Hope this helps.

Comment 4 by Peter Doyle posted on 1/26/2008 at 4:32 PM

Hi,

In the post he doesn't mention pdf forms? Just that he wants an email button - I take it as a contact us type of link.

As above surely this can be done with a href on an image or text?

<cfdocument format="pdf">
<a href="mailto:yourmail@yourisp.com"><img src="Resources/email_add.png" width="16" height="16" border="0"></a>
</cfdocument>

Peter

Comment 5 by Rachel posted on 1/30/2008 at 3:46 AM

Roland is right, you need LiveCycle designer to create the form. It comes with Acrobat Pro (and any version of Creative Suite that includes Acrobat Pro). You can also use a form created in Acrobat (still requires Acrobat Pro, but a little more straightforward).
You can dynamically set where the button sends the email by binding it to a form field (hidden from view with styling) elsewhere in the document, and then setting the value of that form field with ColdFusion.

Comment 6 by gfbj posted on 8/24/2015 at 9:43 PM

FWIW, cfdocument/pdf on CF 10 seems to allow <input>, <input type="checkbox"> but not <input type="button"> (also freaked out, wanted a "treeLock" if a <table> didn't have closing </tr>

Comment 7 (In reply to #6) by Raymond Camden posted on 8/25/2015 at 6:03 AM

I wonder how cfhtmltopdf handles it? I'd test, but I can't use it on a Mac.