Search code examples
coldfusioncoldfusion-9

Adding a Submit button to dynamically uploaded PDF document


PDF documents are uploaded by the dealers to the site. There is no standard whatsoever to these documents. We want to present editable PDF forms to the users which later can be saved in the system after user filled up/edited data in these sheets. I am able to read the pdf, populate it whatever fields can be pre-populated, and also render the editable PDF to the browser. Problem is pdf does not have any Submit button and as much as I know, this can be added only by opening the pdf in acrobat. I tried

  1. rendering the pdf in iframe and a submit button in different frame (as much as foolish it was)
  2. Converting the read pdf as Text and presenting all the form fields as HTML fields to user but got stuck on anything other than input type text (no way to identify if it is checkbox, radio etc)

Solution

  • You have to create the PDF templates with the Submit button included. You'll need to create the PDF using a full copy of Adobe Acrobat, not the reader. You can't edit with the reader. You'll also have to learn how to write JavaScript inside of Acrobat in order to do validation and small interactions in the PDF if needed.

    You're not going to save a copy of the populated PDF, you're going to save the data that was submitted via the PDF form. You can then populate the file for printing, if that's what they want, but the submit button will be part of the PDF that's printed.

    When you need to use a PDF form, just link to it in the browser. When you submit the PDF form, the processing CFM will redirect to the next page in the workflow. We include a cross-site request forgery token as part of the PDF form data for security. If we don't get the token as part of the FORM scoped data, then we don't process it.

    We have a mix of HTML and PDF forms. Generally, our clients hand us existing documents that they want converted for the web. In some cases, we create HTML forms, in others, they prefer we keep the formatting of the document so we use PDFs. You can't dynamically convert the PDFs to HTML forms, you'll have to have someone do that manually to ensure the correct form controls are used (and populated) throughout the form.