Asp To Pdf
Hey all. I indicated in another thread that I would post the solution if I ever figured it out as to how to convert asp to pdf...well, I finally figured it out and I am posting it here for all to see. I am going to spell this out in a rediculously simple step-by step format so that hopefully no one gets hung up like I did. The adobe site is easy to get lost in and registering some of the files had me scratching my head for a while. I figured I would rather have too much info than not enough.
Actually, this process isn't too difficult once you get everything you need. I guess I better clarify that this only works on my personal web server. If you want this to run off of the internet you will need to be able to to have the .dll's mentioned below, registered on the server you are running your site on. I have contacted my host server and I will post back any response from them as to whether or not that is feasible.
Before a file can be transformed from asp to pdf, the asp file must first be transformed into a fdf file. FDF stands for Form Definition File and is used by pdf files to display form data. Basically, FDF is just an easy and efficient way to communicate with pdf files. Ok, so now you are probably asking how do I get my asp file into a pdf file? Good question...see step 2.
Adobe understands that in order for people to want to use their product they need to offer resources to help out developers. So they offer a free resource so that you can turn your asp files into fdf documents. The only catch is that you have to fill out an application and then wait for approval. The process took about 2 weeks for me to get approved so keep this in mind as you are developing your site. You can apply for the right to the fdf toolkit on the adobe web-site at http://partners.adobe.com/public/de.../fdf/topic.html
Click on one of the links on the right side (such as FDF Toolkit for Windows), you will then be directed to a screen where you will have to create an account with adobe. Once your account is created click on the following link:
Fill out this application...be sure that you DON'T use a free web-based email system otherwise they will deny your application. Now patiently wait while they approve your application.
Once you are approved go back to the first link above and download the fdf toolkit. Once this is downloaded you must register two files. To do this open the "FDF Toolkit folder for Windows" and navigate to the following:
Headers and Libraries > Win > FDFACX > FDFACX.Dll
Now copy the FDFACX.Dll file and then navigate here:
C: > Windows > System32
and then paste the FDFACX.Dll file here.
Now get the other .DLL file
Headers and Libraries > Win > C > FDFTK.Dll
Copy the FDFTK.DLL file and then navigate here:
C: > Windows > System32
and then paste the FDFACX.Dll file here.
Now you need to register these .dll files. To do this go to start > run and then either type in or copy and paste the following:
If it registers properly you should get a message indicating that it succeeded. By registering the file above it should automatically take care of the other fdftk.dll file, but if you have problems you may try doing that one too: regsvr32 fdftk.dll
Now you are ready to create your pdf template. I am using adobe 6.0 so those are the steps I will be describing. I am not sure if there are major changes in other versions:
Open adobe 6.0 and go to file > open and then select any document you want to export your asp data into.
Now create the following 3 fields "firstname", "lastname" and "address". To do this you will need to make sure that the "Advanced Editing" toolbar is displayed. To make sure this toolbar is available go to:
"View" > "Toolbars" > "Advanced Editing"
You should see what looks like a gray rectangle with a drop-down arrow beside it. Click on the arrow and select "Text field tool". This will give you a sizeable rectangle that you can place anywhere on the document. Once you place the rectangle a "Text field properties" dialog box should appear (if not right-click on the field and select "properties"). Click on the tab titled "General" and name the field "firstname" and then click on "close". Do the same for the other fields.
Once this is finished saved the document as demo1.pdf
Now you are ready to use an .asp page to convert asp info into fdf data and then open the pdf document so that the fdf data is displayed in the pdf form. Use the code below and then name the file demo1.asp
Now simply place both demo1.pdf and demo1.asp in your personal web server directory and run the demo1.asp page (http://localhost/demo1.asp). When you run the page the demo1.asp should open the pdf file you created and the fields should be completed with the information from above.
<%@ LANGUAGE = VBScript%>
'*** Create the FDF object.
Set FdfAcX = Server.CreateObject("FdfApp.FdfApp")
Set objFdf = FdfAcX.FDFCreate
'*** Set the location of the PDF file you create.
'*** Set the variables with data from the various Request
'*** data name/ value pairs posted from the HTML form. I'm using
'*** rather verbose code here, hopefully to benefit beginners
'*** Use the FDFSetValue method to the PDF's name/value
'*** where the value is one of the variables set above.
objFdf.FDFSetValue "firstname", firstname, Off
objFdf.FDFSetValue "address",address, Off
objFdf.FDFSetValue "lastname",lastname, Off
'*** Use the FDFSetStatus method to display an alert status box.
objFdf.FDFSetStatus "Your Demo form has been created."
'*** Write the data back to the buffer stream.
Response.ContentType = "application/vnd.fdf"
'*** Close the object and clean-up.
Set objFdf = Nothing
Set FdfAcX = Nothing
I tried to keep this as simple as possible so everyone could get the example above working. However, you can see how easy it would be to modify this information. I set up my pages so that I am pulling a list of customers from my database. The user selects the customer and then all of their information is sent to a very clean and tidy pdf document that is easy to print and save as official records. For additional information check out the links below. I was able to get most of this information from theses sites, I simply put it together in a way that is hopefully more current and a bit easier to understand.
I hope this information is beneficial to you. I had to go through the painful steps of figuring out this entire process. Little things like learning how to create the pdf form, downloading the fdf toolkit and registering the .dll's took forever because I had never really done them before. Please let me know if this information works or doesn't work for you.
Last edited by seanbennington; 05-04-2006 at 10:46 PM.
Do you know how to turn your newly created PDF into a "Press Optimized PDF?"
I am working on something similiar, so THANK YOU very much for removing some of the guess work I was going to have to do..
I really haven't used adobe much except for just the basic conversion of documents into pdf format, so I only know the basics. I am not sure if the press optimizer and the PDF Optimizer option is the same thing, but if so I think you can simply create your document then go to the "Advanced" menu item and select "PDF Optimizer". Because the asp information is imported into the pdf form, that page should always be the same, just filled with different form data. So if you optimize it, everytime it opens it should be optimized.
If not, you can also have the data imported into the pdf document and then go to Advanced > PDF Optimize and then save your document with a unique name.
Let me know what you come up with for a solution as you have now made me contemplate optimizing my documents too.
I wonder whether the pdf converter I am testing these days allows pdf to asp convcersion process. Any suggetsion will be appreciated. Thanks in advance.
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)