Error using servlet for external-graphic
Hi all, I'm trying to use a servlet to generate a dynamic image and am seeing the following error: 6/26/02 3:16 PM -- http://localhost:8080/client/DoGetImage?w=200&h=100&leftmargin=1.5 6/26/02 3:16 PM -- Could not load external SVG: The current document is unable to create an element of the requested type (namespace: http://www.w3.org/2000/svg, name: head).Error while creating area : No ImageReader for this type of image (http://localhost:8080/client/DoGet Image?w=200&h=100&leftmargin=1.5) The relevant FO source is: http://localhost:8080/client/DoGetImage?w=200&h=100&leftmargin=1.5"/> The image displays fine in a browser, but after adding some logging code to the servlet it appears that FOP is not calling it at all. Does anybody know what might be causing this error (querystring in the URL, use of a port number, etc)? Much thanks, Joel Stevenson
Re: What kind of TIFF does FOP support
J.Pietschmann wrote: Well, obsolete or not, it works, is available, platform neutral, easy to install and provides support for a wide range of graphics formats, some of them rather obscure. Do you know of a JAI implementation, preferably OSS and/or freely available, which supports all common subformats of TIFF, PNG, BMP and perhaps a few more? Well, that's right and what is more JAI strongly requires at least jdk1.3 :( -- Oleg Tkachenko Multiconn International Ltd
Re: AW: Problem with servlet
[EMAIL PROTECTED] wrote: Thanks for your help. I got the following from my websphere administrator. We've tried to do the changes as mentioned at the end of your e-mail (changing jars and updating admin.config), but the IBM admin server can't restart. If we remove xml4j.jar and the others and replace them by the ones specified, the IBM admin server can't restart because of the lack of ibm xml classes only found in xml4j.jar, and not available in Xerces-1.2.3.jar or Xalan-2.0.0. We've tried to use xml4j.jar with Xerces123 and Xalan200, but problems appears in the running of the server. I managed it even without admin rightes. Goto http://marc.theaimsgroup.com/?l=fop-dev&m=101552169109119&w=2 and search for websphere. J.Pietschmann
Re: AW: Problem with servlet
I got fop successfully running on websphere 3.5 just by adding saxon.jar at the first place in the com.ibm.ejs.sm.adminserver.classpath record of admin.config file (beware about strange syntax \:/), here is my line (websphere 3.5.6, NT4): com.ibm.ejs.sm.adminserver.classpath=d\:/WebSphere/AppServer/lib/saxon.jar;d\:/WebSphere/AppServer/lib/ibmwebas.jar;d\:/WebSphere/AppServer/properties;d\:/WebSphere/AppServer/lib/servlet.jar;d\:/WebSphere/AppServer/lib/webtlsrn.jar;d\:/WebSphere/AppServer/lib/lotusxsl.jar;d\:/WebSphere/AppServer/lib/compat.jar;d\:/WebSphere/AppServer/lib/xalan.jar;d\:/WebSphere/AppServer/lib/ns.jar;d\:/WebSphere/AppServer/lib/ejs.jar;d\:/WebSphere/AppServer/lib/ujc.jar;D\:/PROGRA~1/SQLLIB/java/db2java.zip;d\:/WebSphere/AppServer/lib/repository.jar;d\:/WebSphere/AppServer/lib/admin.jar;d\:/WebSphere/AppServer/lib/swingall.jar;d\:/WebSphere/AppServer/lib/console.jar;d\:/WebSphere/AppServer/lib/was20cm.jar;d\:/WebSphere/AppServer/lib/tasks.jar;d\:/WebSphere/AppServer/lib/xml4j.jar;d\:/WebSphere/AppServer/lib/vaprt.jar;d\:/WebSphere/AppServer/lib/sslight.jar;d\:/WebSphere/AppServer/lib/ibmjndi.jar;d\:/WebSphere/AppServer/lib/deployTool.jar;d\:/WebSphere/AppServer/lib/databeans.jar;d\:/WebSphere/ AppServer/classes;d\:/WebSphere/AppServer/jdk/lib/tools.jar;d\:/WebSphere/AppServer/lib/bsf.jar;d\:/WebSphere/AppServer/lib/dertrjrt.jar;d\:/WebSphere/AppServer/lib/derdbpw.jar;d\:/WebSphere/AppServer/lib/ivjejb35.jar;d:/WebSphere/AppServer/lib/js.jar;d\:/WebSphere/AppServer/lib/js.jar This way saxon's SAX implementation classes override those in old libraries. [EMAIL PROTECTED] wrote: Thanks for your help. I got the following from my websphere administrator. We've tried to do the changes as mentioned at the end of your e-mail (changing jars and updating admin.config), but the IBM admin server can't restart. If we remove xml4j.jar and the others and replace them by the ones specified, the IBM admin server can't restart because of the lack of ibm xml classes only found in xml4j.jar, and not available in Xerces-1.2.3.jar or Xalan-2.0.0. We've tried to use xml4j.jar with Xerces123 and Xalan200, but problems appears in the running of the server. ANy suggestions? Thanks again for your help. -Neeru "J.Pietschman n" To: [EMAIL PROTECTED] <[EMAIL PROTECTED]cc: oo.de> Subject: Re: AW: Problem with servlet 06/21/2002 05:23 PM Please respond to fop-user [EMAIL PROTECTED] wrote: I made the changes but still getting the same error. It's driving me crazy. ANy help will be greatly appreciated. Usually, WebSphere 3.5 comes with an ancient XML tool set. You have to put Xerces-1.2.3.jar and Xalan-2.0.0.jar into the classpath before the old tools. If you have admin access, remove xml4j.jar, a perhaps existing old xerces.jar, lotusxsl.jar from the WebSphere lib and edit the startup scripts so that the newer Xerces and Xalan jars are used. If you have user rights only, start the admin client, go to your application server entry, open the "environment" windoe and add a CLASSPATH environment variable with the newer Xerces and Xalan jars . Better yet, upgrade to 4.0. J.Pietschmann -- Oleg Tkachenko Multiconn International Ltd, Israel
Re: AW: Problem with servlet
Thanks for your help. I got the following from my websphere administrator. We've tried to do the changes as mentioned at the end of your e-mail (changing jars and updating admin.config), but the IBM admin server can't restart. If we remove xml4j.jar and the others and replace them by the ones specified, the IBM admin server can't restart because of the lack of ibm xml classes only found in xml4j.jar, and not available in Xerces-1.2.3.jar or Xalan-2.0.0. We've tried to use xml4j.jar with Xerces123 and Xalan200, but problems appears in the running of the server. ANy suggestions? Thanks again for your help. -Neeru "J.Pietschman n" To: [EMAIL PROTECTED] <[EMAIL PROTECTED]cc: oo.de> Subject: Re: AW: Problem with servlet 06/21/2002 05:23 PM Please respond to fop-user [EMAIL PROTECTED] wrote: > I made the changes but still getting the same error. > It's driving me crazy. ANy help will be greatly appreciated. Usually, WebSphere 3.5 comes with an ancient XML tool set. You have to put Xerces-1.2.3.jar and Xalan-2.0.0.jar into the classpath before the old tools. If you have admin access, remove xml4j.jar, a perhaps existing old xerces.jar, lotusxsl.jar from the WebSphere lib and edit the startup scripts so that the newer Xerces and Xalan jars are used. If you have user rights only, start the admin client, go to your application server entry, open the "environment" windoe and add a CLASSPATH environment variable with the newer Xerces and Xalan jars . Better yet, upgrade to 4.0. J.Pietschmann
RE: Fill a block container area with an SVG
The answer of my question is : Create the svg file of a GUI Component with the same dimension that it should have in the pdf page file. Bye Stefano Barella -Original Message- From: Stefano Barella [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 26, 2002 9:30 AM To: [EMAIL PROTECTED] Subject: Fill a block container area with an SVG Hi, I have a problem, I'm using fop to genere a pdf file and I want to fill a block container with an svg picture. My problem is that I give to the block a precise dimension an position ( ABSOLUTE ) and I'll give to the svg image the same dimensions but it is ignored all directive that I have gaved. The image doen't fill all the rectangle of the block container but it seems to have always a precise dimension, may be a FIXED dimension. My code: http://www.w3.org/2000/svg"; width="9cm" height="11cm"> Can anybody help me ? Bye Stefano Barella
Re: Weird behaviour of Apache fop
Just curious - why are you processing input as string instead of tree? xslt is not text processing language, it's intended for tree transformations. I believe this string processing example is a very convolute analogue of 3 simple xslt templates: Moreover, these templates has advantage over string processing - they are really build output tree by elements, while you are just outputting string values like "foo", that's why fop doesn't see element b here - it's just text node holding *characters* '<', 'b', '>', 'f' etc. This string has to be parsed by xml parser in order to be tree or sax events, that is particular reason you cannot avoid transformation to string and reparsing using this technique. The only reason for using this string-oriented stuff is ill-formed input, like html, but you can use 1) tidy software to get xhtml, 2) html parser (apache has one, libxml is able to parse html also). Willem-Jan van den Bichelaer wrote: Hi, The problem is when we use our template to filter HTML style codes (e.g. ,,), FOP does not do what we want it to do. We use the following template to achieve this: But somehow we don't see anything in the result while running FOP. That's why we used CDATA sections. We then used let's say saxon for transforming the xml into fo-codes, and the gave the fo-file to FOP. Now FOP gives the result we want, so bold text in the FO language. I hope this clarifies the matter a bit. Greetings, Willem -- Oleg Tkachenko Multiconn International Ltd, Israel
RE: Weird behaviour of Apache fop
Hi, The problem is when we use our template to filter HTML style codes (e.g. ,,), FOP does not do what we want it to do. We use the following template to achieve this: But somehow we don't see anything in the result while running FOP. That's why we used CDATA sections. We then used let's say saxon for transforming the xml into fo-codes, and the gave the fo-file to FOP. Now FOP gives the result we want, so bold text in the FO language. I hope this clarifies the matter a bit. Greetings, Willem
RE: Using FOP in Tomcat server
please ignore my prev message thanks -Original Message- From: Kumar, Sunil Sent: Wednesday, June 26, 2002 7:53 AM To: [EMAIL PROTECTED] Subject: RE: Using FOP in Tomcat server trey mcclendon -Original Message- From: Oleg Tkachenko [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 26, 2002 8:53 AM To: [EMAIL PROTECTED] Subject: Re: Using FOP in Tomcat server Chances are you are using tomcat4.02 or 4.03 which have classloader bug, see http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6374. I so, upgrade to tomcat 4.04 or move your jars to tomcat/common/lib. Kumar, Sunil wrote: > Hi, > > I am using tomcat server and i have some problem using fop > i get the following error in the catalina.out file > > > java.lang.ClassNotFoundException: javax.xml.transform.Transformer > at > org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav > a:1394) > at > org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav > a:1243) > at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313) > at java.lang.Class.forName0(Native Method) > at java.lang.Class.forName(Class.java:120) > at org.apache.fop.apps.XSLTInputHandler.getParser(Unknown Source) > at poolinfo.PDFGenerator.getPDFReport(PDFGenerator.java:92) > > > Note : In the log file the relevant jar files (fop,batik, > avalon-framework,xalan-2.3.1)are deployed successfully > can anyone help me on this > > Thanks > Sunil > -- Oleg Tkachenko Multiconn International Ltd, Israel
RE: Using FOP in Tomcat server
trey mcclendon -Original Message- From: Oleg Tkachenko [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 26, 2002 8:53 AM To: [EMAIL PROTECTED] Subject: Re: Using FOP in Tomcat server Chances are you are using tomcat4.02 or 4.03 which have classloader bug, see http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6374. I so, upgrade to tomcat 4.04 or move your jars to tomcat/common/lib. Kumar, Sunil wrote: > Hi, > > I am using tomcat server and i have some problem using fop > i get the following error in the catalina.out file > > > java.lang.ClassNotFoundException: javax.xml.transform.Transformer > at > org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav > a:1394) > at > org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav > a:1243) > at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313) > at java.lang.Class.forName0(Native Method) > at java.lang.Class.forName(Class.java:120) > at org.apache.fop.apps.XSLTInputHandler.getParser(Unknown Source) > at poolinfo.PDFGenerator.getPDFReport(PDFGenerator.java:92) > > > Note : In the log file the relevant jar files (fop,batik, > avalon-framework,xalan-2.3.1)are deployed successfully > can anyone help me on this > > Thanks > Sunil > -- Oleg Tkachenko Multiconn International Ltd, Israel
Re: Using FOP in Tomcat server
Chances are you are using tomcat4.02 or 4.03 which have classloader bug, see http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6374. I so, upgrade to tomcat 4.04 or move your jars to tomcat/common/lib. Kumar, Sunil wrote: Hi, I am using tomcat server and i have some problem using fop i get the following error in the catalina.out file java.lang.ClassNotFoundException: javax.xml.transform.Transformer at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav a:1394) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav a:1243) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:120) at org.apache.fop.apps.XSLTInputHandler.getParser(Unknown Source) at poolinfo.PDFGenerator.getPDFReport(PDFGenerator.java:92) Note : In the log file the relevant jar files (fop,batik, avalon-framework,xalan-2.3.1)are deployed successfully can anyone help me on this Thanks Sunil -- Oleg Tkachenko Multiconn International Ltd, Israel
Re: Using FOP in Tomcat server
I had the same problem, and it solved it self by reputting the xalan jar in the lib dir (inside the web-inf of the application)... and restarting the tomcat... You might wanna try to extract the class files and set them in the classes dir of your web-inf, if this solves the problem, then try to rebuild the jar and put that jar in the lib dir... hope this helps... Hi, I am using tomcat server and i have some problem using fop i get the following error in the catalina.out file java.lang.ClassNotFoundException: javax.xml.transform.Transformer at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav a:1394) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav a:1243) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:120) at org.apache.fop.apps.XSLTInputHandler.getParser(Unknown Source) at poolinfo.PDFGenerator.getPDFReport(PDFGenerator.java:92) Note : In the log file the relevant jar files (fop,batik, avalon-framework,xalan-2.3.1)are deployed successfully can anyone help me on this Thanks Sunil Jochen Maes ICT Development KBC Securities (kbcsecurities.com) Havenlaan 12 Avenue du Port SIF 8683 B-1080 Brussels Belgium Tel: +32 2 429 96 81 GSM: +32 496 57 90 99 E-mail : [EMAIL PROTECTED] This message and any attachments hereto are for the named person's use only. It may contain confidential, proprietary or legally privileged information. You may not, directly or indirectly, use, disclose, distribute, print, or copy any part of this message if you are not the intended recipient. If you have received this e-mail message without being the intended recipient, please notify KBC Securities promptly and delete this e-mail. Any views expressed in this message are those of the individual sender, except where the message states otherwise and the sender is authorised to state them to be the views of KBC Securities. KBC Securities reserves the right to monitor all e-mail communications through its networks and any messages addressed to, received or sent by KBC Securities or its employees are deemed to be professional in nature. The sender or recipient of any messages to or of KBC Securities agrees that those may be read by other employees of KBC Securities than the stated recipient or sender in order to ensure the continuity of work-related activities and allow supervision thereof. KBC Securities does not accept liability for the correct and complete transmission of the information, nor for any delay or interruption of the transmission, nor for damages arising from the use of, or reliance on, the information.
Using FOP in Tomcat server
Hi, I am using tomcat server and i have some problem using fop i get the following error in the catalina.out file java.lang.ClassNotFoundException: javax.xml.transform.Transformer at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav a:1394) at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.jav a:1243) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:313) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:120) at org.apache.fop.apps.XSLTInputHandler.getParser(Unknown Source) at poolinfo.PDFGenerator.getPDFReport(PDFGenerator.java:92) Note : In the log file the relevant jar files (fop,batik, avalon-framework,xalan-2.3.1)are deployed successfully can anyone help me on this Thanks Sunil
RE: Some seemingly "simple" Formatting Questions
I'm actually having the same problems with the keep-with-next property, it just doesn't seem to have ANY effect at all (I tried using it on table rows). There have been some discussions here about this topic, and I think that some people stated that it works, but I still couldn't figure out how they did it... One workaround is to use table-headers, depending on your document structure, you might wanna use this. Kurt -Message d'origine- De : Markus Wiese [mailto:[EMAIL PROTECTED] Envoyé : mercredi, 26. juin 2002 10:40 À : [EMAIL PROTECTED] Objet : Re: Some seemingly "simple" Formatting Questions Hi Paul, 1. Try putting your margin-top in your 2. afaik markers aren't supported yet. 3. try using something like: 4. I had to fiddle a lot with preventing page-breaks, you will have to use the workarounds (using table-cells/ keep-together="always") or wait for the major redesign, I reckon. Please correct, if I'm wrong. markus -Ursprüngliche Nachricht- Von: Thibodeaux, Paul <[EMAIL PROTECTED]> An: [EMAIL PROTECTED] <[EMAIL PROTECTED]> Datum: Mittwoch, 26. Juni 2002 02:25 Betreff: Some seemingly "simple" Formatting Questions >I'm relatively new to using FOP. I've got a document working fairly well, >but am having a difficult time doing a few things that I would have thought >to be "simple". > >1. Cannot set the TOP MARGIN of a "xsl-region-before". >Setting it to anything is ignored and the data is always printed at the very >top of the page. > > margin-top="2cm" margin-left="2cm" >margin-right="2cm" > > >2. Cannot set the FONT of a "fo:retrieve-marker" used in a >"xsl-region-before". >It seems to ignore my font setting and always print the same size. > > retrieve-class-name="mrkState" >retrieve-boundary="page" >retrieve-position="first-starting-within-page"/> > > >3. Cannot set the height of a "fo:leader" to a small amount. >The output is always preceeded by more white space than is desired. > > > space-before="0pt" line-height="1pt"/> > > >4. Problem using "keep-with-next" across page and column breaks of >multi-column pages. >Thanks to Chuck Paussa, I made great headway on better controlling KEEPS in >a multi-column document by putting the data in TABLE CELLS. The >KEEP-TOGETHER seems to work fine within TABLE cells; however, the KEEP-WITH >NEXT does not appear to work. > >Any insights on this would be greatly appreciated. > >Thanks, >Paul Thibodeaux > > > >
Re: Problem with javax.xml.transform.Transformer
J.Pietschmann wrote: I belive the Tomcat site itself mentions it. Other than that, read the installation instructions for Cocoon regarding Tomcat 4.0.3 and the Cocoon FAQ. The generally recommended workaround is to move everything into the Tomcat lib. You are right, that's particular bug 6374, http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6374. -- Oleg Tkachenko Multiconn International Ltd
Re: Some seemingly "simple" Formatting Questions
Hi Paul, 1. Try putting your margin-top in your 2. afaik markers aren't supported yet. 3. try using something like: 4. I had to fiddle a lot with preventing page-breaks, you will have to use the workarounds (using table-cells/ keep-together="always") or wait for the major redesign, I reckon. Please correct, if I'm wrong. markus -Ursprüngliche Nachricht- Von: Thibodeaux, Paul <[EMAIL PROTECTED]> An: [EMAIL PROTECTED] <[EMAIL PROTECTED]> Datum: Mittwoch, 26. Juni 2002 02:25 Betreff: Some seemingly "simple" Formatting Questions >I'm relatively new to using FOP. I've got a document working fairly well, >but am having a difficult time doing a few things that I would have thought >to be "simple". > >1. Cannot set the TOP MARGIN of a "xsl-region-before". >Setting it to anything is ignored and the data is always printed at the very >top of the page. > > margin-top="2cm" margin-left="2cm" >margin-right="2cm" > > >2. Cannot set the FONT of a "fo:retrieve-marker" used in a >"xsl-region-before". >It seems to ignore my font setting and always print the same size. > > retrieve-class-name="mrkState" >retrieve-boundary="page" >retrieve-position="first-starting-within-page"/> > > >3. Cannot set the height of a "fo:leader" to a small amount. >The output is always preceeded by more white space than is desired. > > > space-before="0pt" line-height="1pt"/> > > >4. Problem using "keep-with-next" across page and column breaks of >multi-column pages. >Thanks to Chuck Paussa, I made great headway on better controlling KEEPS in >a multi-column document by putting the data in TABLE CELLS. The >KEEP-TOGETHER seems to work fine within TABLE cells; however, the KEEP-WITH >NEXT does not appear to work. > >Any insights on this would be greatly appreciated. > >Thanks, >Paul Thibodeaux > > > >
Fill a block container area with an SVG
Hi, I have a problem, I'm using fop to genere a pdf file and I want to fill a block container with an svg picture. My problem is that I give to the block a precise dimension an position ( ABSOLUTE ) and I'll give to the svg image the same dimensions but it is ignored all directive that I have gaved. The image doen't fill all the rectangle of the block container but it seems to have always a precise dimension, may be a FIXED dimension. My code: http://www.w3.org/2000/svg"; width="9cm" height="11cm"> Can anybody help me ? Bye Stefano Barella
Re: Embedded FOP question.
Subject: Re: Embedded FOP question. From: Davor Cengija <[EMAIL PROTECTED]> === [EMAIL PROTECTED] wrote: > I've been using the FopServlet as the basis for my servlet app which takes > a DOM document, stores it to an xml file, then uses XSLTInputHandler to > convert to fo and output the pdf. Now I'm getting to the point where I > want to eliminate the xml file and convert using the DOM object or a > serialized > string of the xml. It looks to me like it can't be done with the > XSLTInputHandler class because it requires java.io.File parameters. I'm > looking at XSLTransform to transform the DOM document input to a DOM > document containing FO output using the xsl file. Just wondering if this > is the best approach and then how to best use the FO DOM document to > output the > pdf. If anyone knows where I can find some good sample code (or if you > have a sample yourself), I would appreciate the tips. Here is how I convert DOM to PDF directly, without creating files or string buffers. Methods are pulled out from different classes and not very pretty formatted but I hope you'll manage it: // creates FO DOM from node with transformer protected Document createFo(Node node, Transformer transformer) throws TransformerConfigurationException, TransformerException { Document doc = null; try { // helper to create DOM documents doc = XMLUtilities.createDocument(); } catch (Exception e) { throw new TransformerConfigurationException(); } Node n = doc.importNode(node, true); doc.appendChild(n); DOMSource domSource = new DOMSource(doc); DOMResult domResult = new DOMResult(); transformer.transform(domSource, domResult); Node n2 = domResult.getNode(); return (Document) n2; } // transforms FO DOM into PDF and sends it to OutputStream protected void createPdf(Document doc, OutputStream fOut) throws IOException, FOPException { InputSource inputSource = XmlHelper.dom2inputSource(doc); ByteArrayOutputStream out = new ByteArrayOutputStream(); Hierarchy hierarchy = Hierarchy.getDefaultHierarchy(); Logger log = hierarchy.getLoggerFor("fop"); log.setPriority(Priority.ERROR); File userConfigFile = new File(FOP_CONFIG); Options options = new Options(userConfigFile); Driver driver = new Driver(inputSource, out); driver.setLogger(log); driver.setRenderer(Driver.RENDER_PDF); driver.run(); byte[] content = out.toByteArray(); fOut.write(content); out.flush(); out.close(); } /* import org.apache.xalan.serialize.Serializer; import org.apache.xalan.serialize.SerializerFactory; import org.apache.xalan.templates.OutputProperties; */ // and dom2inputSource, which converts any DOM to SAX InputSource without // writing to disk public static InputSource dom2inputSource(Document doc) throws IOException { InputSource is = null; Serializer serializer = SerializerFactory.getSerializer( OutputProperties.getDefaultMethodProperties("xml")); CharArrayWriter caw = new CharArrayWriter(); serializer.setWriter(caw); serializer.asDOMSerializer().serialize(doc); is = new InputSource(new java.io.CharArrayReader(caw.toCharArray())); return is; } -- Davor Cengija [EMAIL PROTECTED] = "Nicht in die Augen bringen!"
RE: FOPServlet and XML string
I resolved my problem with pointers from J.Pietschmann. Here is my code: public static void renderXML(Document document, String xslFile, HttpServletResponse response) throws ServletException { try { ByteArrayOutputStream out = new ByteArrayOutputStream(); response.setContentType("application/pdf"); Driver driver =new Driver(); //driver.setOutputStream(response.getOutputStream()); driver.setOutputStream(out); driver.setRenderer(Driver.RENDER_PDF); Transformer transformer=TransformerFactory.newInstance().newTransformer(new StreamSource(xslFile)); transformer.transform(new DOMSource(document), new SAXResult(driver.getContentHandler())); byte[] content = out.toByteArray(); response.setContentLength(content.length); response.getOutputStream().write(content); response.getOutputStream().flush(); } catch (Exception ex) { throw new ServletException(ex); } } HTH, Mike -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 25, 2002 2:45 PM To: [EMAIL PROTECTED] Subject: RE: FOPServlet and XML string I'm having the same issues, so if you find a solution, please post. But, it seems like you could use the XALAN function XSLTransform to convert a DOM document or a string using an XSL file to either a FO file or another DOM document. XSLTInputHandler will only take java.io.File parameters, but I've seen examples of using the JAXP Transformer to do the job as well. See: http://www.devx.com/xml/articles/vp101201/vp101201-1.asp. It seems as if this could be modified to use a StringReader and/or StringWriter. Let me know if you have any luck. Mike -Original Message- From: Mo, Jennifer [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 25, 2002 2:17 PM To: [EMAIL PROTECTED] Subject: FOPServlet and XML string Does anyone know how to modify the FOPServlet so that it takes in a XML string instead of a XML file? The XSLTInputHandler class (which inherits from InputHandler) seems to only take in a file but not a String. i'm stuck. Any ideas or suggestion?
RE: Embedded FOP question.
Thanks for your help! I needed to change it to use a ByteArray so that I could set the content length for IE. Other than that it worked great. Thanks again. Mike -Original Message- From: J.Pietschmann [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 25, 2002 4:51 PM To: [EMAIL PROTECTED] Subject: Re: Embedded FOP question. [EMAIL PROTECTED] wrote: > I've been using the FopServlet as the basis for my servlet app which takes a > DOM document, stores it to an xml file, then uses XSLTInputHandler to > convert to fo and output the pdf. Now I'm getting to the point where I want > to eliminate the xml file and convert using the DOM object or a serialized > string of the xml. It looks to me like it can't be done with the > XSLTInputHandler class because it requires java.io.File parameters. I'm > looking at XSLTransform to transform the DOM document input to a DOM > document containing FO output using the xsl file. Just wondering if this is > the best approach and then how to best use the FO DOM document to output the > pdf. If anyone knows where I can find some good sample code (or if you have > a sample yourself), I would appreciate the tips. There is sample code in the archive at http://marc.theaimsgroup.com/?l=fop-user&r=1&w=2# http://marc.theaimsgroup.com/?l=fop-dev&r=1&w=2# For producing and rendering a DOM, look up javax.xml.transform.dom.DOMResult in the JAXP documentation coming with your XSLT processor and look for render(Document) in src/org/apache/fop/apps/Driver.java Unless you need to manipulate the intermediate DOM, it is usually more effective to use SAX to tie the XSLT processor to the FOP driver, for example http://marc.theaimsgroup.com/?l=fop-user&m=102400770318682&w=2 J.Pietschmann
RE: Some seemingly "simple" Formatting Questions
> 1. Cannot set the TOP MARGIN of a "xsl-region-before". > Setting it to anything is ignored and the data is always > printed at the very > top of the page. > > margin-top="2cm" margin-left="2cm" > margin-right="2cm" > I think margin is a property of the page-master (correct me if I'm wrong), but you are right in that it doesn't seem to work on the region-before, even in the examples provided with FOP. Probably a bug. > > 2. Cannot set the FONT of a "fo:retrieve-marker" used in a > "xsl-region-before". > It seems to ignore my font setting and always print the same size. > > retrieve-class-name="mrkState" > retrieve-boundary="page" > retrieve-position="first-starting-within-page"/> > Set this property on the block around fo:marker instead. > > 3. Cannot set the height of a "fo:leader" to a small amount. > The output is always preceeded by more white space than is desired. > > >space-after.optimum="4pt" > space-before="0pt" line-height="1pt"/> > Can't comment on the height but haven't noticed the leading whitespace. The properties on preceding block perhaps? What else is on this line? > > 4. Problem using "keep-with-next" across page and column breaks of > multi-column pages. > Thanks to Chuck Paussa, I made great headway on better > controlling KEEPS in > a multi-column document by putting the data in TABLE CELLS. The > KEEP-TOGETHER seems to work fine within TABLE cells; > however, the KEEP-WITH > NEXT does not appear to work. Odd, keep-together only worked for me on table-rows, not cells. Haven't used keep-with-next. Regards, Roland
Some seemingly "simple" Formatting Questions
I'm relatively new to using FOP. I've got a document working fairly well, but am having a difficult time doing a few things that I would have thought to be "simple". 1. Cannot set the TOP MARGIN of a "xsl-region-before". Setting it to anything is ignored and the data is always printed at the very top of the page. 2. Cannot set the FONT of a "fo:retrieve-marker" used in a "xsl-region-before". It seems to ignore my font setting and always print the same size. 3. Cannot set the height of a "fo:leader" to a small amount. The output is always preceeded by more white space than is desired. 4. Problem using "keep-with-next" across page and column breaks of multi-column pages. Thanks to Chuck Paussa, I made great headway on better controlling KEEPS in a multi-column document by putting the data in TABLE CELLS. The KEEP-TOGETHER seems to work fine within TABLE cells; however, the KEEP-WITH NEXT does not appear to work. Any insights on this would be greatly appreciated. Thanks, Paul Thibodeaux