Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Generate PDF file

Contributor ,
Sep 16, 2011 Sep 16, 2011

I know how to create a PDF in the browser using the <cfdocument> tag, but what I'd like to do is be able to create a PDF of an HTML form when the user submits the form.  So rather than the user submitting the form and a PDF opening in the browser, the user submits the form and sees a "thank you for completing our form" message with an link to download the PDF version on the page.  If they leave the page, the PDF remains on the server for us to commect at the end of the survey period.

Is this possible?

844
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Valorous Hero , Sep 16, 2011 Sep 16, 2011

Think of it like creating a preview page in html. You display whatever #form# field values the user entered in some table or div tags. Just wrap that html in cfdocument tags to generate the pdf. Use the "filename" attribute to save the pdf to disk. Just be sure to use unique file names for each submission to avoid overwriting existing files. Though if you are saving the survey information to a database, you could also create the pdf's on demand rather than saving them to disk.

Translate
LEGEND ,
Sep 16, 2011 Sep 16, 2011

It's possible.

What's the part you are having difficutly with?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Sep 16, 2011 Sep 16, 2011

Think of it like creating a preview page in html. You display whatever #form# field values the user entered in some table or div tags. Just wrap that html in cfdocument tags to generate the pdf. Use the "filename" attribute to save the pdf to disk. Just be sure to use unique file names for each submission to avoid overwriting existing files. Though if you are saving the survey information to a database, you could also create the pdf's on demand rather than saving them to disk.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Sep 16, 2011 Sep 16, 2011

Ooooh! I totally missed the filename attrib of <cfdocument>.

So I can just built the page I want using <cfoutput> just like the way I did when I was generating it in the browser, but the filename attrib will write it to a file instead?

I'm off to try that!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Sep 16, 2011 Sep 16, 2011
LATEST

That worked!  Thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Sep 16, 2011 Sep 16, 2011

Sure it is possible.

Looking at the documentation and you should see the parameters that deal with writing the PDF output to a file rather then sending it to the client.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources