Solved

Creating Dynamic pdf files with ASP

Posted on 2002-04-24
17
740 Views
Last Modified: 2012-06-21
When I recently did my taxes with Turbotax Web, I noticed at the end of filling in a bunch of forms...up popped the acrobat reader and voila!  All my data was magically printed on the form.  I am embarking on project that will need similar forms generation. - Enter data into an HTML form and then with a click of the finished button show the data in a nicely formatted pdf file.  Can someone tell me what I would need to do this with ASP or ASP.net?  Include useful links for extra credit...Thanks
0
Comment
Question by:kenadelglass
  • 5
  • 3
  • 3
  • +5
17 Comments
 
LVL 11

Expert Comment

by:thunderchicken
Comment Utility
activepdf.com

It's the ONLY way to do this successfully.
0
 
LVL 6

Expert Comment

by:snoegler
Comment Utility
... or switch to PHP :)
0
 
LVL 6

Expert Comment

by:snoegler
Comment Utility
If the data you want to put into the PDF is already in a database, you could use an external report generator which generates PDF. In my company, we used a crystal reports backend for that purpose.
0
 
LVL 6

Expert Comment

by:snoegler
Comment Utility
Should read: "in the company i am working in" :)
0
 
LVL 18

Expert Comment

by:mgfranz
Comment Utility
Acrobat 5 does dynamic PDF files...
0
 
LVL 9

Expert Comment

by:AlfaNoMore
Comment Utility
This one's free:
http://www.websupergoo.com/abcpdf-1.htm

And this one's not, but looks better supported:
http://www.dreamscape.it/eng/index.htm

They're both usable from within ASP.
0
 

Expert Comment

by:davebeer
Comment Utility
I've found the best bit of code to do this with, is SEDTechs' iSEDQuickPDF.

http://pdf.sedtech.co.za/index.html

It is very quick, perfect for on-the-fly creation of PDFs. And quite reasonably priced. I found it very easy to program with.

At only $50US, it's a LOT cheaper than activePDF.

As an example, this is how you'd create a simple PDF document.

--begin code--

' Create the object
Dim PDF As iSED.iSEDQuickPDF
Set PDF = CreateObject("iSED.iSEDQuickPDF")

' Set the RegistrationKey and the Destination
PDF.RegistrationKey = "3E20-2579-DACA-39F1"
PDF.Destination = "c:\helloworld.pdf"

' Put some text onto the page
PDF.DrawText(72, 576, "Hello World!")

' Generate the file
Call PDF.WriteFile

' Free the object
Set PDF = Nothing

--end code--


Not a lot to it really. :-)

Cheers,
Dave.
0
 
LVL 46

Expert Comment

by:fritz_the_blank
Comment Utility
Unfortunately, http://www.websupergoo.com/abcpdf-1.htm is no longer free...

Fritz the Blank
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Accepted Solution

by:
Internetbias earned 150 total points
Comment Utility
Actually you can do it yourself for free, in a sense - If you already have the PDF form created.

Since the PDF form already has the form fields created and labeled, all you really need to do is create an FDF file.  The FDF file contains several important pieces of information:  The PDF file location you want to populate with data, and the data for the form fields.

All you need to do essentially is have your ASP script write a text file, named whatever.fdf.

The guts of teh file look like this:

___________________________________

%FDF-1.2%âãÏÓ
1 0 obj
<<
/FDF << /Fields [
___________________________________
This is the HEADER




___________________________________

<< /V (VALUE_DATA)/T (NAME_OF_FORM_FIELD_IN_PDF)>>
<< /V (VALUE_DATA)/T (NAME_OF_FORM_FIELD_IN_PDF)>>
<< /V (VALUE_DATA)/T (NAME_OF_FORM_FIELD_IN_PDF)>>

___________________________________
This is the IMPORTANT PART.  Loop through all your fields to make this fit your needs or data.




___________________________________
]
/F (http://www.nhdinc.com/forms/designcriteria.pdf)>>
>>
endobj
trailer
<<
/Root 1 0 R

>>
%%EOF
___________________________________
This is the FOOTER


Here's the important and cool thing about using the FDF method I am talking about here.  You can record all this data, even if you don't require it all, and use the FDF file for MULTIPLE PDFs!

It may not be as nifty as purchasing someone else's code, but you can do it yourself for free.

Douglas@internetbias.com
http://www.internetbias.com/
0
 
LVL 18

Expert Comment

by:mgfranz
Comment Utility
Hmm... interesting.  But then what, rename the .fdf to .pdf?
0
 

Expert Comment

by:davebeer
Comment Utility
No. The PDF loads the fields with the data from the FDF. You need to create a PDF with the form fields for it to work. But it does work well.
0
 
LVL 1

Expert Comment

by:Internetbias
Comment Utility
Correct, the FDF file calls to the PDF file.  The PDF pulls the data you stored in the FDF and populates itself.

davebeer is correct, you need to have a PDF with formfields already created for this to work.  After doing it once successfully, you'll never forget.
0
 
LVL 18

Expert Comment

by:mgfranz
Comment Utility
So if I create a .fdf file with the data field called "temp", and a .pdf with a form field "temp", what do I call?  The .fdf or the .pdf?  

I assume I can call the .fdf in this manner;

strFilePath = Server.MapPath("data\test.fdf")
ContentType = "application/pdf"
Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = 1
objStream.LoadFromFile strFilePath
Response.AddHeader "Content-Disposition", "attachment; filename="&strFilePath
     Response.ContentType = ContentType
     Response.BinaryWrite objStream.Read
     Response.Flush
...
0
 
LVL 18

Expert Comment

by:mgfranz
Comment Utility
Or;

ContentType = "application/vnd.fdf"
0
 
LVL 18

Expert Comment

by:mgfranz
Comment Utility
Or;

ContentType = "application/vnd.adobe.xfdf"
0
 
LVL 1

Expert Comment

by:Internetbias
Comment Utility
You can name the fdf anything you want.  Same with the PDF.  Just make sure that the footer...
_________________________________

]
/F (local or remote location of PDF)>>
>>
endobj
trailer
<<
/Root 1 0 R

>>
%%EOF
_________________________________

...calls to the same name.  Otherwise you are correct abou tthe field names and storing them in the FDF.

I've even done a response.redirect to the FDF file and had it run correctly.  The only limitation is that the person accessing the file MUST have Acrobat Reader installed.  Otherwise it will load the FDF text information into the browser window.  Not pretty.

Internetbias
http://www.internetbias.com/
0
 
LVL 1

Author Comment

by:kenadelglass
Comment Utility
I think the answer to this question has been exhausted.  Thanks to all but Internetbias had most unique solution and it is free...
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now