totally new to FOP -Please help me
I am very new to fop - just started learningit. 1)I downloaded the fop - 0.20.5 - binary version for windows (.zip) 2)Unzipped it (D:\fop-0.20.5) 3)Trying to run D:\fop-0.20.5\fop.bat - i geto/p as mentioned in the document http://apache.oss.eznetsols.org/xml/fop/ 4)but at the end of itigot error - [ERROR] No Input file specified What's missing ? JAVA_HOME is set properly. 5)I also tried to compile one servlet (which i got it from web) -iput inside the classpath fop.jar and all other jars those inside fop.bat. But i am getting errors -- import org.apache.fop.apps.Driver;import org.apache.fop.apps.XSLTInputHandler;import org.apache.fop.render.Renderer;import org.apache.avalon.framework.logger.Logger;import org.apache.avalon.framework.logger.ConsoleLogger; import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import javax.servlet.ServletException;import javax.servlet.ServletOutputStream;import javax.xml.transform.stream.StreamSource;import javax.xml.transform.Transformer;import javax.xml.transform.TransformerFactory;import java.io.IOException;import java.io.ByteArrayOutputStream;import java.util.logging.Level; public class FOPServlet extends HttpServlet{ private String xmlFile = "data.xml"; private String xslFile = "pdfGen.xsl"; protected void doGet(HttpServletRequest httpServletRequest, HttpServletResponsehttpServletResponse) throws ServletException, IOException { // set up a FOP driver Driver driver = new Driver(); // set up the logger for the driver Logger logger = new ConsoleLogger(ConsoleLogger.LEVEL_INFO); driver.setLogger(logger); try { //set the renderer to be PDF driver.setRenderer(Driver.RENDER_PDF); //create the input from the XSLT transform XSLTInputHandler inputHandler = new XSLTInputHandler(xmlFile, xslFile); // now prepare the outputStrean ByteArrayOutputStream outStream = new ByteArrayOutputStream(); //set the driver outputStream driver.setOutputStream(outStream); //do the XSLT driver.render(inputHandler.getParser(), inputHandler.getInputSource()); //now that the content is written in the output stream, //get ready to send the response back to browser byte[] content = outStream.toByteArray(); httpServletResponse.setContentLength(content.length); // set the MIME-TYPE httpServletResponse.setContentType("application/pdf"); //write the content httpServletResponse.getOutputStream().write(content); httpServletResponse.getOutputStream().flush(); } catch (Exception e) { e.printStackTrace(); } } } I am getting following: D:\jakarta-tomcat-5.0.25\webapps\rr_lesson_1\WEB-INF\classes\FOPServlet.java:1: package org.apache.fop.apps does not existimport org.apache.fop.apps.Driver; ^D:\jakarta-tomcat-5.0.25\webapps\rr_lesson_1\WEB-INF\classes\FOPServlet.java:2: package org.apache.fop.apps does not existimport org.apache.fop.apps.XSLTInputHandler; ^D:\jakarta-tomcat-5.0.25\webapps\rr_lesson_1\WEB-INF\classes\FOPServlet.java:3: package org.apache.fop.render does not existimport org.apache.fop.render.Renderer; ^D:\jakarta-tomcat-5.0.25\webapps\rr_lesson_1\WEB-INF\classes\FOPServlet.java:4: package org.apache.avalon.framework.logger does not existimport org.apache.avalon.framework.logger.Logger; ^D:\jakarta-tomcat-5.0.25\webapps\rr_lesson_1\WEB-INF\classes\FOPServlet.java:5: package org.apache.avalon.framework.logger does not existimport org.apache.avalon.framework.logger.ConsoleLogger; ^ Please can anybody give me clue about it ? What am i doing wrong ? regards Manisha Do you Yahoo!? Meet the all-new My Yahoo! Try it today!
Re: totally new to FOP -Please help me
hi all, 1) no 5 i could sort it out - some silly mistake in my classpath settings. but no 4 is as it is regards Manisha Manisha Sathe [EMAIL PROTECTED] wrote: I am very new to fop - just started learningit. 1)I downloaded the fop - 0.20.5 - binary version for windows (.zip) 2)Unzipped it (D:\fop-0.20.5) 3)Trying to run D:\fop-0.20.5\fop.bat - i geto/p as mentioned in the document http://apache.oss.eznetsols.org/xml/fop/ 4)but at the end of itigot error - [ERROR] No Input file specified What's missing ? JAVA_HOME is set properly. 5)I also tried to compile one servlet (which i got it from web) -iput inside the classpath fop.jar and all other jars those inside fop.bat. But i am getting errors -- import org.apache.fop.apps.Driver;import org.apache.fop.apps.XSLTInputHandler;import org.apache.fop.render.Renderer;import org.apache.avalon.framework.logger.Logger;import org.apache.avalon.framework.logger.ConsoleLogger; import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import javax.servlet.ServletException;import javax.servlet.ServletOutputStream;import javax.xml.transform.stream.StreamSource;import javax.xml.transform.Transformer;import javax.xml.transform.TransformerFactory;import java.io.IOException;import java.io.ByteArrayOutputStream;import java.util.logging.Level; public class FOPServlet extends HttpServlet{ private String xmlFile = "data.xml"; private String xslFile = "pdfGen.xsl"; protected void doGet(HttpServletRequest httpServletRequest, HttpServletResponsehttpServletResponse) throws ServletException, IOException { // set up a FOP driver Driver driver = new Driver(); // set up the logger for the driver Logger logger = new ConsoleLogger(ConsoleLogger.LEVEL_INFO); driver.setLogger(logger); try { //set the renderer to be PDF driver.setRenderer(Driver.RENDER_PDF); //create the input from the XSLT transform XSLTInputHandler inputHandler = new XSLTInputHandler(xmlFile, xslFile); // now prepare the outputStrean ByteArrayOutputStream outStream = new ByteArrayOutputStream(); //set the driver outputStream driver.setOutputStream(outStream); //do the XSLT driver.render(inputHandler.getParser(), inputHandler.getInputSource()); //now that the content is written in the output stream, //get ready to send the response back to browser byte[] content = outStream.toByteArray(); httpServletResponse.setContentLength(content.length); // set the MIME-TYPE httpServletResponse.setContentType("application/pdf"); //write the content httpServletResponse.getOutputStream().write(content); httpServletResponse.getOutputStream().flush(); } catch (Exception e) { e.printStackTrace(); } } } I am getting following: D:\jakarta-tomcat-5.0.25\webapps\rr_lesson_1\WEB-INF\classes\FOPServlet.java:1: package org.apache.fop.apps does not existimport org.apache.fop.apps.Driver; ^D:\jakarta-tomcat-5.0.25\webapps\rr_lesson_1\WEB-INF\classes\FOPServlet.java:2: package org.apache.fop.apps does not existimport org.apache.fop.apps.XSLTInputHandler; ^D:\jakarta-tomcat-5.0.25\webapps\rr_lesson_1\WEB-INF\classes\FOPServlet.java:3: package org.apache.fop.render does not existimport org.apache.fop.render.Renderer; ^D:\jakarta-tomcat-5.0.25\webapps\rr_lesson_1\WEB-INF\classes\FOPServlet.java:4: package org.apache.avalon.framework.logger does not existimport org.apache.avalon.framework.logger.Logger; ^D:\jakarta-tomcat-5.0.25\webapps\rr_lesson_1\WEB-INF\classes\FOPServlet.java:5: package org.apache.avalon.framework.logger does not existimport org.apache.avalon.framework.logger.ConsoleLogger; ^ Please can anybody give me clue about it ? What am i doing wrong ? regards Manisha Do you Yahoo!?Meet the all-new My Yahoo! Try it today! Do you Yahoo!? Read only the mail you want - Yahoo! Mail SpamGuard.
Re: totally new to FOP -Please help me
On Feb 6, 2005, at 9:38 PM, Manisha Sathe wrote: I am very new to fop - just started learning it. 1)I downloaded the fop - 0.20.5 - binary version for windows (.zip) 2)Unzipped it (D:\fop-0.20.5) 3)Trying to run D:\fop-0.20.5\fop.bat - i get o/p as mentioned in the document http://apache.oss.eznetsols.org/xml/fop/ 4)but at the end of it i got error - [ERROR] No Input file specified What's missing ? JAVA_HOME is set properly. Running D:\fop-0.20.5\fop.bat will give you the the usage, since you're not specifying an input file. The USAGE is: fop [options] [-fo|-xml] infile [-xsl file] [-awt|-pdf|-mif|-pcl|-ps|-txt|-svg|-at|-print] outfile (the | means OR so [-fo|-xml] means either -fo OR -xml) In the case of: D:\fop-0.20.5\fop.bat -xsl foo.xsl -xml foo.xml -pdf foo.pdf foo.xsl represents the xslt file foo.xml represents an input xml file foo.pdf represents an output pdf file and so on... Here're six examples: D:\fop-0.20.5\fop.bat foo.fo foo.pdf D:\fop-0.20.5\fop.bat -fo foo.fo -pdf foo.pdf (does the same as the previous line) D:\fop-0.20.5\fop.bat -xsl foo.xsl -xml foo.xml -pdf foo.pdf D:\fop-0.20.5\fop.bat foo.fo -mif foo.mif D:\fop-0.20.5\fop.bat foo.fo -print or fop -print foo.fo D:\fop-0.20.5\fop.bat foo.fo -awt 5)I also tried to compile one servlet (which i got it from web) - i put inside the classpath fop.jar and all other jars those inside fop.bat. But i am getting errors I don't know about servlets or embedding, but this might help: http://xml.apache.org/fop/servlets.html Please can anybody give me clue about it ? What am i doing wrong ? regards Manisha Hope this helps! Web Maestro Clay -- [EMAIL PROTECTED] - http://homepage.mac.com/webmaestro/ My religion is simple. My religion is kindness. - HH The 14th Dalai Lama of Tibet - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: totally new to FOP -Please help me
Please refer to documents in your D:\fop-0.20.5\build\site\running.html the command line args are fop -fo input.fo -pdf output.pdf here input.fo is your input file and output.pdf is your output file hope this clarifies you. Cheers Eugene Manisha Sathe [EMAIL PROTECTED] 07.02.2005 11:50 Please respond to [EMAIL PROTECTED] To [EMAIL PROTECTED] cc Subject Re: totally new to FOP -Please help me hi all, 1) no 5 i could sort it out - some silly mistake in my classpath settings. but no 4 is as it is regards Manisha Manisha Sathe [EMAIL PROTECTED] wrote: I am very new to fop - just started learning it. 1)I downloaded the fop - 0.20.5 - binary version for windows (.zip) 2)Unzipped it (D:\fop-0.20.5) 3)Trying to run D:\fop-0.20.5\fop.bat - i get o/p as mentioned in the document http://apache.oss.eznetsols.org/xml/fop/ 4)but at the end of it i got error - [ERROR] No Input file specified What's missing ? JAVA_HOME is set properly. 5)I also tried to compile one servlet (which i got it from web) - i put inside the classpath fop.jar and all other jars those inside fop.bat. But i am getting errors -- import org.apache.fop.apps.Driver; import org.apache.fop.apps.XSLTInputHandler; import org.apache.fop.render.Renderer; import org.apache.avalon.framework.logger.Logger; import org.apache.avalon.framework.logger.ConsoleLogger; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.ServletException; import javax.servlet.ServletOutputStream; import javax.xml.transform.stream.StreamSource; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import java.io.IOException; import java.io.ByteArrayOutputStream; import java.util.logging.Level; public class FOPServlet extends HttpServlet { private String xmlFile = data.xml; private String xslFile = pdfGen.xsl; protected void doGet(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException { // set up a FOP driver Driver driver = new Driver(); // set up the logger for the driver Logger logger = new ConsoleLogger(ConsoleLogger.LEVEL_INFO); driver.setLogger(logger); try { //set the renderer to be PDF driver.setRenderer(Driver.RENDER_PDF); //create the input from the XSLT transform XSLTInputHandler inputHandler = new XSLTInputHandler(xmlFile, xslFile); // now prepare the outputStrean ByteArrayOutputStream outStream = new ByteArrayOutputStream(); //set the driver outputStream driver.setOutputStream(outStream); //do the XSLT driver.render(inputHandler.getParser(), inputHandler.getInputSource()); //now that the content is written in the output stream, //get ready to send the response back to browser byte[] content = outStream.toByteArray(); httpServletResponse.setContentLength(content.length); // set the MIME-TYPE httpServletResponse.setContentType(application/pdf); //write the content httpServletResponse.getOutputStream().write(content); httpServletResponse.getOutputStream().flush(); } catch (Exception e) { e.printStackTrace(); } } } I am getting following: D:\jakarta-tomcat-5.0.25\webapps\rr_lesson_1\WEB-INF\classes\FOPServlet.java:1: package org.apache.fop.apps does not exist import org.apache.fop.apps.Driver; ^ D:\jakarta-tomcat-5.0.25\webapps\rr_lesson_1\WEB-INF\classes\FOPServlet.java:2: package org.apache.fop.apps does not exist import org.apache.fop.apps.XSLTInputHandler; ^ D:\jakarta-tomcat-5.0.25\webapps\rr_lesson_1\WEB-INF\classes\FOPServlet.java:3: package org.apache.fop.render does not exist import org.apache.fop.render.Renderer; ^ D:\jakarta-tomcat-5.0.25\webapps\rr_lesson_1\WEB-INF\classes\FOPServlet.java:4: package org.apache.avalon.framework.logger does not exist import org.apache.avalon.framework.logger.Logger; ^ D:\jakarta-tomcat-5.0.25\webapps\rr_lesson_1\WEB-INF\classes\FOPServlet.java:5: package org.apache.avalon.framework.logger does not exist import org.apache.avalon.framework.logger.ConsoleLogger; ^ Please can anybody give me clue about it ? What am i doing wrong ? regards Manisha Do you Yahoo!? Meet the all-new My Yahoo! Try it today! Do you Yahoo!? Read only the mail you want - Yahoo! Mail SpamGuard.
New To Fop
Hello; I need a advice from more experienced FOP developers. The web project I am contracting on needs to be able to generate a PDF version of various pages the user may be browsing. As of now the only input I have to work with is the HTML of the page being displayed (the system can return it to me as a string during runtime). Speed is a factor so a requirements is the system only creates a new PDF document when the previously created one is out of synch with the content. I need to get this done fast. Can someone suggest what they think the best strategy will be for me to create the document? Should I use an .fo input? Transform the HTML into XML and process it with an XSL? Any tips from some who has done something similar would be very very helpful and appreciated. With Regards, Luke - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: New To Fop
Luke, What you are looking to do comes up pretty often on this list so you will probably get quite a bit of help. Here's mine What you will need to do is go from HTML into XML then into FO, once in FO, FOP can render it quite quickly into a PDF, your browser can even be used as the delivery mechanism. I wrote a Java Servlet which is invoked via an HTML page link, the links passes the necessary parameters. In your case that will be a reference to the original HMTL file. The next step is not obvious, hence this e-mail. Not all HTML is XML-ready, humans make mistakes which most browsers correct, unbalanced and missing tags for example. Also some tags need to be doctored, BR and HR come to mind, these have no closing tags. What I did here was to use the Tidy engine/library to fix up my HTML into valid XML. Now the job gets pretty easy... The next step is to develop an XSL transform which takes HMTL tags and create FO XML. I have some transforms which I am very happy to share with you, as will others. Nobody has a complete HTML to FO implementation as this would be huge but you can get most of the transform working quickly and then add to it as needed. Once you have the FO XML -- BOOM, a few lines of code later and you've got your PDF. The servlet I wrote actually communicates back to the browser every second and fakes an elapsed progress timer. We had to do this as we originally were running on slow hardware and have very impatient. With our hardware these days the transform and PDF generation runs so quickly, the interaction is more of a nuisance that an aid. But at the time that is what the boss wanted, so I wrote it. --will smime.p7s Description: S/MIME cryptographic signature
Re: New To Fop
Thanks Will. This is the sort of advice I was hoping for. From the little I have played with FOP this makes sense. I would be interested in looking at any code you would like to share. Luke - Original Message - From: Will Gilbert [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, January 04, 2005 11:30 AM Subject: Re: New To Fop Luke, What you are looking to do comes up pretty often on this list so you will probably get quite a bit of help. Here's mine What you will need to do is go from HTML into XML then into FO, once in FO, FOP can render it quite quickly into a PDF, your browser can even be used as the delivery mechanism. I wrote a Java Servlet which is invoked via an HTML page link, the links passes the necessary parameters. In your case that will be a reference to the original HMTL file. The next step is not obvious, hence this e-mail. Not all HTML is XML-ready, humans make mistakes which most browsers correct, unbalanced and missing tags for example. Also some tags need to be doctored, BR and HR come to mind, these have no closing tags. What I did here was to use the Tidy engine/library to fix up my HTML into valid XML. Now the job gets pretty easy... The next step is to develop an XSL transform which takes HMTL tags and create FO XML. I have some transforms which I am very happy to share with you, as will others. Nobody has a complete HTML to FO implementation as this would be huge but you can get most of the transform working quickly and then add to it as needed. Once you have the FO XML -- BOOM, a few lines of code later and you've got your PDF. The servlet I wrote actually communicates back to the browser every second and fakes an elapsed progress timer. We had to do this as we originally were running on slow hardware and have very impatient. With our hardware these days the transform and PDF generation runs so quickly, the interaction is more of a nuisance that an aid. But at the time that is what the boss wanted, so I wrote it. --will - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: New To Fop
Hi Will; What I did here was to use the Tidy engine/library to fix up my HTML into valid XML. This library you are referring to. Which package is it part of? Thanks, Luke - Original Message - From: Will Gilbert [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, January 04, 2005 11:30 AM Subject: Re: New To Fop Luke, What you are looking to do comes up pretty often on this list so you will probably get quite a bit of help. Here's mine What you will need to do is go from HTML into XML then into FO, once in FO, FOP can render it quite quickly into a PDF, your browser can even be used as the delivery mechanism. I wrote a Java Servlet which is invoked via an HTML page link, the links passes the necessary parameters. In your case that will be a reference to the original HMTL file. The next step is not obvious, hence this e-mail. Not all HTML is XML-ready, humans make mistakes which most browsers correct, unbalanced and missing tags for example. Also some tags need to be doctored, BR and HR come to mind, these have no closing tags. What I did here was to use the Tidy engine/library to fix up my HTML into valid XML. Now the job gets pretty easy... The next step is to develop an XSL transform which takes HMTL tags and create FO XML. I have some transforms which I am very happy to share with you, as will others. Nobody has a complete HTML to FO implementation as this would be huge but you can get most of the transform working quickly and then add to it as needed. Once you have the FO XML -- BOOM, a few lines of code later and you've got your PDF. The servlet I wrote actually communicates back to the browser every second and fakes an elapsed progress timer. We had to do this as we originally were running on slow hardware and have very impatient. With our hardware these days the transform and PDF generation runs so quickly, the interaction is more of a nuisance that an aid. But at the time that is what the boss wanted, so I wrote it. --will - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]