gpalat
03-08-2006, 07:15 AM
is there a way to convert an .xml document to .pdf document through an .asp page? also is it possible to manipulate this file in many ways such as edit, add comments, save and many more?
|
Click to See Complete Forum and Search --> : xml to pdf gpalat 03-08-2006, 07:15 AM is there a way to convert an .xml document to .pdf document through an .asp page? also is it possible to manipulate this file in many ways such as edit, add comments, save and many more? johngalt 04-04-2006, 03:26 PM you can do it with xsl:fo I am just learning about it now you should be able to get a free fop for Windows and Linux fop = form object processor = it does the transfroming here's an example I wrote: http://www.bangboompow.com/examples/barcode/ another example, it needs some error trapping still. If images are too big for one page it gets stuck in an endless loop: http://www.bangboompow.com/examples/jpg2pdf.htm here's a lot of information: http://www.w3.org/Style/XSL/ seanbennington 04-04-2006, 06:04 PM Johngalt, I would love it if you shared your source code as to how to do this conversion. I have been searching for a long time trying to figure out how to do this. Any help would be great! Sean johngalt 04-04-2006, 06:43 PM I user a 4GL called EZgen that runs mostly on Linux and UNIX - there is a Windows version in the works. you can use Replace (Ctrl-H) in most Windows applications like Word and Notepad if you don't need to do it dynamically this site is using something, do View Source on this page and look at what it does to things like <THIS> and <THAT> - they must have some simple PHP character escape routine. another way might be create a file with a txt extension and open it in a frame or just show the enitre thing like this: http://www.bangboompow.com/examples/test.txt that's sort of how I am showing this source code: http://www.bangboompow.com/examples/barcode/ seanbennington 04-04-2006, 07:36 PM Thanks for the prompt response. I am actually trying to have my pdf files dynamically created from a db. First I pull the data into my asp page and then I convert it into an xml file. I have this part functioning properly, but my problem is that I know almost nothing about xml and am trying to figure out how to convert from xml into the pdf. The example isn't working, but I am assuming that it is supposed to convert the xml into pdf. I viewed the source code and it seems fairly straight forward, excluding the xml. I would love to hear any additional ideas or thoughts you might have on the subject...thanks! Sean johngalt 04-05-2006, 11:41 AM this should be working now http://www.bangboompow.com/examples/barcode/ It looks like I answered someone elses question with my last response to you. I use fop in Linux, you can get free versions of it for Windows to. Form Object Processor can take data from and create a pdf based on an xsl stylesheet. http://xmlgraphics.apache.org/fop/ I am just learning about this myself seanbennington 04-05-2006, 12:40 PM That is really cool. What type of coding are you using to convert from xml to pdf (i.e. aps, cgi, etc..). Is it possible to see your source code for the conversion page? Also do you know if you can designate an input field on a previously created form to recieve the xml data? Sorry, to keep hounding you with questions, but I will take any help I can get. Thanks, Sean johngalt 04-05-2006, 12:53 PM I am using a cgi script to talk to my Linux box and run a script that calls a 4GL called EZgen that calls an fop command line then redirects the pdf back to the browser window. Anything that can make a system call to a fop statement should be able to do the same. I need to figure out a way to make the fop run faster. Here is an example of a B2B project I'm working on. Click on Statements and then click on one of the invoices. www.fastenersnow.com/b2b login: demo password: demo123 an example fop line looks like this (all one line): JAVA_HOME=/usr/java/jre1.5.0_01;export JAVA_HOME;export CLASSPATH=$CLASSPATH:/u/green/documentconnection/reports/barcode4j/barcode4j -1.0/lib/avalon-framework-4.1.5.jar:/u/green/documentconnection/reports/barcode4j/barcode4j-1.0/lib/commons-cli-1.0.jar;cd /u/green/ documentconnection/reports;./fop/fop-0.20.5/fop.sh -xml /u/tmp/000342-000024.xml -xsl /u/green/documentconnection/reports/default/in voice.xsl /u/tmp/000342-0023.pdf 2>/dev/null seanbennington 04-05-2006, 01:46 PM Your demo is exactly what I was hoping to create. I am trying to do a similar thing except I want to take a patient's information and have it fill out an adobe form. I like the design and ease of use too. If you figure out how to increase your speed let me know. On a different note, I have been doing some research of my own and have found some good asp scripts, but they require the adobe toolkit which I am waiting for approval for. There is also a nice component called abcpdf which is great and does exactly what I am hoping for it to do, but I am hoping to charge for my program and I can't justify an increase in the cost of the program for $300, which is why I am trying to find a work around. Anyways, thanks for all of your help and good luck with your program! Sean johngalt 04-05-2006, 01:50 PM there is an open source program with tons of features: PDF Toolkit http://www.accesspdf.com/index.php?topic=pdftk more links I found useful... http://www.documentconnection.com/links/ gpalat 04-11-2006, 04:44 AM thank you johngalt for the answers to all these questions... i think i will deal with this matter in depth always with your help:):) seanbennington 04-11-2006, 10:18 AM I have been researching this for a while and I think I have figured out how to do this, but I need to implement it first. If it works I will post the solution here for all to see. Sean gpalat 04-12-2006, 02:28 AM thanx seanbennington for the thought... we will be looking forward for your post:) seanbennington 05-04-2006, 11:13 PM Hey all. I indicated previously that I would post the solution if I ever figured out 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. I don't run my web-site off of my own server so I have asked them if they would be willing to install the fdf toolkit onto their server. I will post back any response from them as to whether or not that is feasible. Step 1: 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. 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/developer/acrobat/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: http://partners.adobe.com/public/developer/en/acrobat/fdf/fdf_application.pdf 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. Step 3: 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. Step 4: 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: regsvr32 fdfacx.dll 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 Step 5: 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 Step 5: 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 <%@ LANGUAGE = VBScript%> <% '*** Create the FDF object. Set FdfAcX = Server.CreateObject("FdfApp.FdfApp") Dim objFdf Set objFdf = FdfAcX.FDFCreate '*** Set the location of the PDF file you create. objFdf.FDFSetFile "http://localhost/demo1.pdf" '*** 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 firstname="Joe" lastname="Blow" address="1234 Nonyabusiness" '*** 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" Response.BinaryWrite objFdf.FDFSaveToBuf '*** Close the object and clean-up. objFdf.FDFClose Set objFdf = Nothing Set FdfAcX = Nothing Response.end %> 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. 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. http://www.planetpdf.com/developer/article.asp?contentid=6492&ra&mp http://www.15seconds.com/Issue/990902.htm http://www.nickhodge.com/nhodge/mungenet/mungenetengine.php?mcid=352 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. Good luck, Sean webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |