Patrick
Patrick

Reputation: 2577

coldfusion show pdf on page

I know coldfusion has extensive pdf support, but I'm not sure if this is possible. I was given a pdf form and told to make it so it is both filled out online, the data is captured, and the form can be printed.

Obviously, I can create an html page that looks like the document, save everything, generate the filled pdf form, etc.

Alternately, I think I can show the pdf, have them fill it, then grab the form data. I'm not entirely sure I can do this though, because I would need to detect when they are done filling it out.

But I was thinking it would be nice if I could do it this way - Show the pdf embedded on the webpage, let them fill it out and print it, then capture everything when they are done. I was looking through the CF documentation (cfpdf cfhttp, etc), but not finding exactly what I need. Is this an option?

Upvotes: 1

Views: 1312

Answers (2)

Sathish Chelladurai
Sathish Chelladurai

Reputation: 690

We can show the pdf on page using cfheader and cfdocument tags. We can only show the pdf on webpage using the following example code.

<cfsavecontent name="pdfcontent">

//Here what you need to show the pdf

</cfsavecontent>

<cfheader name="Content-Disposition" value="filename=Mydocument.pdf">
    <cfdocument format="pdf" orientation = "landscape" bookmark="Yes" marginleft=".25" marginright=".25" marginTop = ".25" marginbottom=".75" scale="90">
            <cfoutput> #pdfcontent# </cfoutput>
    </cfdocument>

Upvotes: 1

Mark A Kruger
Mark A Kruger

Reputation: 7193

You can extract the data from a PDF using the cfpdfform tag or as an HTTP Post. Here's a link to the docs on how to do that, but it depends on how you set up the PDF itself. You can edit your PDF form to actually submit just the formdata to a given CF page. It arrives on the page in a struct tied to the form name (ie. #form.form1.Fields.blah# etc.). Dump it out to deipher it (it's kind of convoluted) So you could fire print and submit from within the PDF.

The second way is to submit the PDF itself as a file. In this case you use the cfpdform tag - not well documented or widely used. Both approaches are covered lightly in the link above. Good luck!

Upvotes: 1

Related Questions