[ERROR] Image not found
Hello I used a simple example on the Internet about how to use FOP in java (http://javaboutique.internet.com/tutorials/FOP/): - I Created a simple Java application with a class that takes an XML and converts it into a PDF (using a XSL) containing an image. The name of my class is Process.java and it has a method process. It works fine when called directly as a java application. - I Created a simple web service that just call this process method of that class. However, when i call the web service, i get an error: [ERROR] Image not found: img/logo.gif = The PDF is created but without the image. Here is the code of my Process.java class: public static String process(String xml, String xsl) { String sResult = null; try { ByteArrayOutputStream foOut = new ByteArrayOutputStream(); ByteArrayOutputStream bOut = new ByteArrayOutputStream(); InputStream iss = Process.class.getClassLoader().getResourceAsStream(brique); copyFile(new BufferedInputStream(iss), bOut); SAXBuilder builder = new SAXBuilder(); Document document = builder.build(new ByteArrayInputStream(xml.getBytes())); TransformerFactory factory = TransformerFactory.newInstance(); InputStream iXsl = Process.class.getClassLoader().getResourceAsStream(xsl); StreamSource iSource = new StreamSource(iXsl); Transformer foTrans = factory.newTransformer(iSource); StreamSource strSourceXML = new StreamSource(new ByteArrayInputStream(xml.getBytes())); foTrans.transform(strSourceXML, new StreamResult(foOut)); foOut.flush(); ByteArrayOutputStream pdfOut = new ByteArrayOutputStream(); TransformerFactory tFactoryFO2PDF = TransformerFactory.newInstance(); Transformer pdfTrans = tFactoryFO2PDF.newTransformer(); FopFactory fopFactory = FopFactory.newInstance(); FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, pdfOut); Result res = new SAXResult(fop.getDefaultHandler()); StreamSource streamSourceXml = new StreamSource(new ByteArrayInputStream(foOut.toByteArray())); pdfTrans.transform(streamSourceXml, res); java.io.File file = new java.io.File(d:/res.pdf); FileOutputStream foStream = new FileOutputStream(file); pdfOut.writeTo(foStream); } catch(Exception e) { e.printStackTrace(); } return sResult; } private static boolean copyFile(InputStream in, OutputStream out) { try { int c; while ((c = in.read()) != -1) out.write(c); in.close(); out.close(); } catch (IOException io) { return false; } return true; } The code of my web service is just: public static String process(String xml, String xsl) { String sResult = null; try { sResult = Process.process(xml, xsl); System.out.println(sss); } catch(Exception e) { e.printStackTrace(); } return sResult; } The web service has the JAR of the Java application in his classpath. The content of the Jar file is the following one: NamePath briques.xsd logo.gif img\ Manifest.mf meta-inf\ Process.class tst saxon-licence.lic xsl2.xslt I call the web service with the following parameters: xml = ?xml version='1.0' encoding='UTF-8'?+ Catalog+ Book+ TitleMastering EJB/Title+ AuthorEd Roman/Author+ Price$45.00/Price+ /Book+ Book+ TitleDesign Patterns/Title+ AuthorErich Gamma/Author+ Price$50.00/Price
Re: [ERROR] Image not found
Hi, you must implementing the UriResolver and set your fopFactory with it. fopFactoy.setUriResolver() regards, Philippe 2010/2/18 pjmorce pjcarva...@gmail.com Hello I used a simple example on the Internet about how to use FOP in java (http://javaboutique.internet.com/tutorials/FOP/): - I Created a simple Java application with a class that takes an XML and converts it into a PDF (using a XSL) containing an image. The name of my class is Process.java and it has a method process. It works fine when called directly as a java application. - I Created a simple web service that just call this process method of that class. However, when i call the web service, i get an error: [ERROR] Image not found: img/logo.gif = The PDF is created but without the image. Here is the code of my Process.java class: public static String process(String xml, String xsl) { String sResult = null; try { ByteArrayOutputStream foOut = new ByteArrayOutputStream(); ByteArrayOutputStream bOut = new ByteArrayOutputStream(); InputStream iss = Process.class.getClassLoader().getResourceAsStream(brique); copyFile(new BufferedInputStream(iss), bOut); SAXBuilder builder = new SAXBuilder(); Document document = builder.build(new ByteArrayInputStream(xml.getBytes())); TransformerFactory factory = TransformerFactory.newInstance(); InputStream iXsl = Process.class.getClassLoader().getResourceAsStream(xsl); StreamSource iSource = new StreamSource(iXsl); Transformer foTrans = factory.newTransformer(iSource); StreamSource strSourceXML = new StreamSource(new ByteArrayInputStream(xml.getBytes())); foTrans.transform(strSourceXML, new StreamResult(foOut)); foOut.flush(); ByteArrayOutputStream pdfOut = new ByteArrayOutputStream(); TransformerFactory tFactoryFO2PDF = TransformerFactory.newInstance(); Transformer pdfTrans = tFactoryFO2PDF.newTransformer(); FopFactory fopFactory = FopFactory.newInstance(); FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, pdfOut); Result res = new SAXResult(fop.getDefaultHandler()); StreamSource streamSourceXml = new StreamSource(new ByteArrayInputStream(foOut.toByteArray())); pdfTrans.transform(streamSourceXml, res); java.io.File file = new java.io.File(d:/res.pdf); FileOutputStream foStream = new FileOutputStream(file); pdfOut.writeTo(foStream); } catch(Exception e) { e.printStackTrace(); } return sResult; } private static boolean copyFile(InputStream in, OutputStream out) { try { int c; while ((c = in.read()) != -1) out.write(c); in.close(); out.close(); } catch (IOException io) { return false; } return true; } The code of my web service is just: public static String process(String xml, String xsl) { String sResult = null; try { sResult = Process.process(xml, xsl); System.out.println(sss); } catch(Exception e) { e.printStackTrace(); } return sResult; } The web service has the JAR of the Java application in his classpath. The content of the Jar file is the following one: NamePath briques.xsd logo.gif img\ Manifest.mf meta-inf\ Process.class tst saxon-licence.lic xsl2.xslt I call the web service with the following parameters: xml = ?xml version='1.0' encoding='UTF-8'?+ Catalog+ Book+ TitleMastering EJB/Title+ AuthorEd Roman/Author+ Price$45.00/Price+ /Book+ Book+ TitleDesign Patterns/Title+ AuthorErich Gamma/Author+ Price$50.00/Price+ /Book+ Book+ TitleEffective Java/Title+ AuthorJosch Bloch/Author+ Price$30.00/Price+ /Book + /Catalog; xsl = xsl2.xslt; In the xsl2.xslt I have a part of code like this to insert the image on the pdf: ... fo:block fo:external-graphic src=img/logo.gif/ /fo:block ... The XSL is found in the JAR because
Re: [ERROR] Image not found
Hi, It is more of a URL problem, try pass URL 'file:/img/logo.gif' instead of relative path. Thanks, Venkat. philippe voncken wrote: Hi, you must implementing the UriResolver and set your fopFactory with it. fopFactoy.setUriResolver() regards, Philippe 2010/2/18 pjmorce pjcarva...@gmail.com mailto:pjcarva...@gmail.com Hello I used a simple example on the Internet about how to use FOP in java (http://javaboutique.internet.com/tutorials/FOP/): - I Created a simple Java application with a class that takes an XML and converts it into a PDF (using a XSL) containing an image. The name of my class is Process.java and it has a method process. It works fine when called directly as a java application. - I Created a simple web service that just call this process method of that class. However, when i call the web service, i get an error: [ERROR] Image not found: img/logo.gif = The PDF is created but without the image. Here is the code of my Process.java class: public static String process(String xml, String xsl) { String sResult = null; try { ByteArrayOutputStream foOut = new ByteArrayOutputStream(); ByteArrayOutputStream bOut = new ByteArrayOutputStream(); InputStream iss = Process.class.getClassLoader().getResourceAsStream(brique); copyFile(new BufferedInputStream(iss), bOut); SAXBuilder builder = new SAXBuilder(); Document document = builder.build(new ByteArrayInputStream(xml.getBytes())); TransformerFactory factory = TransformerFactory.newInstance(); InputStream iXsl = Process.class.getClassLoader().getResourceAsStream(xsl); StreamSource iSource = new StreamSource(iXsl); Transformer foTrans = factory.newTransformer(iSource); StreamSource strSourceXML = new StreamSource(new ByteArrayInputStream(xml.getBytes())); foTrans.transform(strSourceXML, new StreamResult(foOut)); foOut.flush(); ByteArrayOutputStream pdfOut = new ByteArrayOutputStream(); TransformerFactory tFactoryFO2PDF = TransformerFactory.newInstance(); Transformer pdfTrans = tFactoryFO2PDF.newTransformer(); FopFactory fopFactory = FopFactory.newInstance(); FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, pdfOut); Result res = new SAXResult(fop.getDefaultHandler()); StreamSource streamSourceXml = new StreamSource(new ByteArrayInputStream(foOut.toByteArray())); pdfTrans.transform(streamSourceXml, res); java.io.File file = new java.io.File(d:/res.pdf); FileOutputStream foStream = new FileOutputStream(file); pdfOut.writeTo(foStream); } catch(Exception e) { e.printStackTrace(); } return sResult; } private static boolean copyFile(InputStream in, OutputStream out) { try { int c; while ((c = in.read()) != -1) out.write(c); in.close(); out.close(); } catch (IOException io) { return false; } return true; } The code of my web service is just: public static String process(String xml, String xsl) { String sResult = null; try { sResult = Process.process(xml, xsl); System.out.println(sss); } catch(Exception e) { e.printStackTrace(); } return sResult; } The web service has the JAR of the Java application in his classpath. The content of the Jar file is the following one: NamePath briques.xsd logo.gif img\ Manifest.mf meta-inf\ Process.class tst saxon-licence.lic xsl2.xslt I call the web service with the following parameters: xml = ?xml version='1.0' encoding='UTF-8'?+ Catalog+ Book+ TitleMastering EJB/Title+ AuthorEd Roman/Author+ Price$45.00/Price+ /Book
Re: [ERROR] Image not found
Thanks for your answer. I am not familiarized with URIResolver but I check it and, if I understood, I must implement it creating a new class that implements the URIResolver class and the method resolve(String href, String base) In the javadoc the definition of both arguments are: href - An href attribute, which may be relative or absolute. base - The base URI in effect when the href attribute was encountered. If I am correct HRef is the filename. So my URIResolver will have img/logo.gif as href parameter. Correct? And in the case that I dont know the name of my image indicated on the XSL? how can I solve the problem? thank you regards Philippe Voncken wrote: Hi, you must implementing the UriResolver and set your fopFactory with it. fopFactoy.setUriResolver() regards, Philippe 2010/2/18 pjmorce pjcarva...@gmail.com Hello I used a simple example on the Internet about how to use FOP in java (http://javaboutique.internet.com/tutorials/FOP/): - I Created a simple Java application with a class that takes an XML and converts it into a PDF (using a XSL) containing an image. The name of my class is Process.java and it has a method process. It works fine when called directly as a java application. - I Created a simple web service that just call this process method of that class. However, when i call the web service, i get an error: [ERROR] Image not found: img/logo.gif = The PDF is created but without the image. Here is the code of my Process.java class: public static String process(String xml, String xsl) { String sResult = null; try { ByteArrayOutputStream foOut = new ByteArrayOutputStream(); ByteArrayOutputStream bOut = new ByteArrayOutputStream(); InputStream iss = Process.class.getClassLoader().getResourceAsStream(brique); copyFile(new BufferedInputStream(iss), bOut); SAXBuilder builder = new SAXBuilder(); Document document = builder.build(new ByteArrayInputStream(xml.getBytes())); TransformerFactory factory = TransformerFactory.newInstance(); InputStream iXsl = Process.class.getClassLoader().getResourceAsStream(xsl); StreamSource iSource = new StreamSource(iXsl); Transformer foTrans = factory.newTransformer(iSource); StreamSource strSourceXML = new StreamSource(new ByteArrayInputStream(xml.getBytes())); foTrans.transform(strSourceXML, new StreamResult(foOut)); foOut.flush(); ByteArrayOutputStream pdfOut = new ByteArrayOutputStream(); TransformerFactory tFactoryFO2PDF = TransformerFactory.newInstance(); Transformer pdfTrans = tFactoryFO2PDF.newTransformer(); FopFactory fopFactory = FopFactory.newInstance(); FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, pdfOut); Result res = new SAXResult(fop.getDefaultHandler()); StreamSource streamSourceXml = new StreamSource(new ByteArrayInputStream(foOut.toByteArray())); pdfTrans.transform(streamSourceXml, res); java.io.File file = new java.io.File(d:/res.pdf); FileOutputStream foStream = new FileOutputStream(file); pdfOut.writeTo(foStream); } catch(Exception e) { e.printStackTrace(); } return sResult; } private static boolean copyFile(InputStream in, OutputStream out) { try { int c; while ((c = in.read()) != -1) out.write(c); in.close(); out.close(); } catch (IOException io) { return false; } return true; } The code of my web service is just: public static String process(String xml, String xsl) { String sResult = null; try { sResult = Process.process(xml, xsl); System.out.println(sss); } catch(Exception e) { e.printStackTrace(); } return sResult; } The web service has the JAR of the Java application in his classpath. The content of the Jar file is the following one: NamePath briques.xsd logo.gif img\ Manifest.mf meta-inf\ Process.class tst saxon-licence.lic xsl2.xslt I call the web service with the following parameters: xml = ?xml version='1.0' encoding='UTF-8'?+ Catalog+ Book+ TitleMastering EJB/Title+ AuthorEd Roman/Author+ Price$45.00/Price+ /Book
Re: [ERROR] Image not found
I tried your suggestion: in the XSL I have now the following code and the problem remains: fo:block fo:external-graphic src=url('file:/img/logo.gif')/ /fo:block However, i also tried to put this and it worked: fo:block fo:external-graphic src=jar:file:///D:/eclipse_galileo/eclipse/TstFOP/TstFOP.jar!/img/logo.gif/ /fo:block It worked, but obvious reasons I cannot put this on the XSL that will be on production... :( Hi, It is more of a URL problem, try pass URL 'file:/img/logo.gif' instead of relative path. Thanks, Venkat. philippe voncken wrote: Hi, you must implementing the UriResolver and set your fopFactory with it. fopFactoy.setUriResolver() regards, Philippe -- View this message in context: http://old.nabble.com/-ERROR--Image-not-found-tp27636263p27637052.html Sent from the FOP - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org
Re: [ERROR] Image not found
Yes, it's right. implement your UriResolver, set the fopFactory and debug your programme. You will see that you pass in your resolve(String href, String base) method when fop search your image. in href you'll see your image file name and so you can plugged your real image with the inputStream resolve method return. So you can put your image in the classpath and use as : resolve(String href, String base) { return YourUriResolver.class.getResourceAsStream(href); } or : public class SimpleUriResolver implements URIResolver { /** * Instantiates a new fop uri resolver. */ public SimpleUriResolver() { super(); } /* * (non-Javadoc) * @see javax.xml.transform.URIResolver#resolve(java.lang.String, java.lang.String) */ public Source resolve(String href, String base) throws TransformerException { Source src; final String file = file:; if (href.startsWith(file)) { src = new StreamSource(new File(href.substring(file.length(; } else { src = new StreamSource(SimpleUriResolver.class.getResourceAsStream(href)); } return src; } } As you want :) Philippe 2010/2/18 pjmorce pjcarva...@gmail.com Thanks for your answer. I am not familiarized with URIResolver but I check it and, if I understood, I must implement it creating a new class that implements the URIResolver class and the method resolve(String href, String base) In the javadoc the definition of both arguments are: href - An href attribute, which may be relative or absolute. base - The base URI in effect when the href attribute was encountered. If I am correct HRef is the filename. So my URIResolver will have img/logo.gif as href parameter. Correct? And in the case that I dont know the name of my image indicated on the XSL? how can I solve the problem? thank you regards Philippe Voncken wrote: Hi, you must implementing the UriResolver and set your fopFactory with it. fopFactoy.setUriResolver() regards, Philippe 2010/2/18 pjmorce pjcarva...@gmail.com Hello I used a simple example on the Internet about how to use FOP in java (http://javaboutique.internet.com/tutorials/FOP/): - I Created a simple Java application with a class that takes an XML and converts it into a PDF (using a XSL) containing an image. The name of my class is Process.java and it has a method process. It works fine when called directly as a java application. - I Created a simple web service that just call this process method of that class. However, when i call the web service, i get an error: [ERROR] Image not found: img/logo.gif = The PDF is created but without the image. Here is the code of my Process.java class: public static String process(String xml, String xsl) { String sResult = null; try { ByteArrayOutputStream foOut = new ByteArrayOutputStream(); ByteArrayOutputStream bOut = new ByteArrayOutputStream(); InputStream iss = Process.class.getClassLoader().getResourceAsStream(brique); copyFile(new BufferedInputStream(iss), bOut); SAXBuilder builder = new SAXBuilder(); Document document = builder.build(new ByteArrayInputStream(xml.getBytes())); TransformerFactory factory = TransformerFactory.newInstance(); InputStream iXsl = Process.class.getClassLoader().getResourceAsStream(xsl); StreamSource iSource = new StreamSource(iXsl); Transformer foTrans = factory.newTransformer(iSource); StreamSource strSourceXML = new StreamSource(new ByteArrayInputStream(xml.getBytes())); foTrans.transform(strSourceXML, new StreamResult(foOut)); foOut.flush(); ByteArrayOutputStream pdfOut = new ByteArrayOutputStream(); TransformerFactory tFactoryFO2PDF = TransformerFactory.newInstance(); Transformer pdfTrans = tFactoryFO2PDF.newTransformer(); FopFactory fopFactory = FopFactory.newInstance(); FOUserAgent foUserAgent = fopFactory.newFOUserAgent(); Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, pdfOut); Result res = new SAXResult(fop.getDefaultHandler()); StreamSource streamSourceXml = new StreamSource(new ByteArrayInputStream(foOut.toByteArray())); pdfTrans.transform(streamSourceXml, res); java.io.File file = new java.io.File(d:/res.pdf); FileOutputStream foStream = new FileOutputStream(file); pdfOut.writeTo(foStream); } catch(Exception e) { e.printStackTrace(); } return sResult; } private static boolean copyFile(InputStream
AW: [ERROR] Image not found
Hi pjmorce, Assuming TstFOP.jar is on the server and found by your application server, what happens if you use fo:block fo:external-graphic src=url('file:TstFOP.jar!/img/logo.gif')/ /fo:block Mit freundlichen Grüßen Georg Datterl -- Kontakt -- Georg Datterl Geneon media solutions gmbh Gutenstetter Straße 8a 90449 Nürnberg HRB Nürnberg: 17193 Geschäftsführer: Yong-Harry Steiert Tel.: 0911/36 78 88 - 26 Fax: 0911/36 78 88 - 20 www.geneon.de Weitere Mitglieder der Willmy MediaGroup: IRS Integrated Realization Services GmbH:www.irs-nbg.de Willmy PrintMedia GmbH:www.willmy.de Willmy Consult Content GmbH: www.willmycc.de -Ursprüngliche Nachricht- Von: pjmorce [mailto:pjcarva...@gmail.com] Gesendet: Donnerstag, 18. Februar 2010 11:47 An: fop-users@xmlgraphics.apache.org Betreff: Re: [ERROR] Image not found I tried your suggestion: in the XSL I have now the following code and the problem remains: fo:block fo:external-graphic src=url('file:/img/logo.gif')/ /fo:block However, i also tried to put this and it worked: fo:block fo:external-graphic src=jar:file:///D:/eclipse_galileo/eclipse/TstFOP/TstFOP.jar!/img/logo.gif/ /fo:block It worked, but obvious reasons I cannot put this on the XSL that will be on production... :( Hi, It is more of a URL problem, try pass URL 'file:/img/logo.gif' instead of relative path. Thanks, Venkat. philippe voncken wrote: Hi, you must implementing the UriResolver and set your fopFactory with it. fopFactoy.setUriResolver() regards, Philippe -- View this message in context: http://old.nabble.com/-ERROR--Image-not-found-tp27636263p27637052.html Sent from the FOP - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org - To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org
Re: [ERROR] Image not found
Sorry, with this xsl it'll work in root element classpath : fo:block fo:external-graphic src=url('/logo.gif')/ /fo:block Philippe 2010/2/18 philippe voncken m...@philippevoncken.com With my SimpleUriResolver() you must use xsl as follow: fo:block fo:external-graphic src=url('logo.gif')/ /fo:block if logo.gif is in your classpath root element, it will work. Philippe 2010/2/18 Georg Datterl gdatt...@geneon.de Hi pjmorce, Assuming TstFOP.jar is on the server and found by your application server, what happens if you use fo:block fo:external-graphic src=url('file:TstFOP.jar!/img/logo.gif')/ /fo:block Mit freundlichen Grüßen Georg Datterl -- Kontakt -- Georg Datterl Geneon media solutions gmbh Gutenstetter Straße 8a 90449 Nürnberg HRB Nürnberg: 17193 Geschäftsführer: Yong-Harry Steiert Tel.: 0911/36 78 88 - 26 Fax: 0911/36 78 88 - 20 www.geneon.de Weitere Mitglieder der Willmy MediaGroup: IRS Integrated Realization Services GmbH:www.irs-nbg.de Willmy PrintMedia GmbH:www.willmy.de Willmy Consult Content GmbH: www.willmycc.de -Ursprüngliche Nachricht- Von: pjmorce [mailto:pjcarva...@gmail.com] Gesendet: Donnerstag, 18. Februar 2010 11:47 An: fop-users@xmlgraphics.apache.org Betreff: Re: [ERROR] Image not found I tried your suggestion: in the XSL I have now the following code and the problem remains: fo:block fo:external-graphic src=url('file:/img/logo.gif')/ /fo:block However, i also tried to put this and it worked: fo:block fo:external-graphic src=jar:file:///D:/eclipse_galileo/eclipse/TstFOP/TstFOP.jar!/img/logo.gif/ /fo:block It worked, but obvious reasons I cannot put this on the XSL that will be on production... :( Hi, It is more of a URL problem, try pass URL 'file:/img/logo.gif' instead of relative path. Thanks, Venkat. philippe voncken wrote: Hi, you must implementing the UriResolver and set your fopFactory with it. fopFactoy.setUriResolver() regards, Philippe -- View this message in context: http://old.nabble.com/-ERROR--Image-not-found-tp27636263p27637052.html Sent from the FOP - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org - To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org
Re: [ERROR] Image not found
With my SimpleUriResolver() you must use xsl as follow: fo:block fo:external-graphic src=url('logo.gif')/ /fo:block if logo.gif is in your classpath root element, it will work. Philippe 2010/2/18 Georg Datterl gdatt...@geneon.de Hi pjmorce, Assuming TstFOP.jar is on the server and found by your application server, what happens if you use fo:block fo:external-graphic src=url('file:TstFOP.jar!/img/logo.gif')/ /fo:block Mit freundlichen Grüßen Georg Datterl -- Kontakt -- Georg Datterl Geneon media solutions gmbh Gutenstetter Straße 8a 90449 Nürnberg HRB Nürnberg: 17193 Geschäftsführer: Yong-Harry Steiert Tel.: 0911/36 78 88 - 26 Fax: 0911/36 78 88 - 20 www.geneon.de Weitere Mitglieder der Willmy MediaGroup: IRS Integrated Realization Services GmbH:www.irs-nbg.de Willmy PrintMedia GmbH:www.willmy.de Willmy Consult Content GmbH: www.willmycc.de -Ursprüngliche Nachricht- Von: pjmorce [mailto:pjcarva...@gmail.com] Gesendet: Donnerstag, 18. Februar 2010 11:47 An: fop-users@xmlgraphics.apache.org Betreff: Re: [ERROR] Image not found I tried your suggestion: in the XSL I have now the following code and the problem remains: fo:block fo:external-graphic src=url('file:/img/logo.gif')/ /fo:block However, i also tried to put this and it worked: fo:block fo:external-graphic src=jar:file:///D:/eclipse_galileo/eclipse/TstFOP/TstFOP.jar!/img/logo.gif/ /fo:block It worked, but obvious reasons I cannot put this on the XSL that will be on production... :( Hi, It is more of a URL problem, try pass URL 'file:/img/logo.gif' instead of relative path. Thanks, Venkat. philippe voncken wrote: Hi, you must implementing the UriResolver and set your fopFactory with it. fopFactoy.setUriResolver() regards, Philippe -- View this message in context: http://old.nabble.com/-ERROR--Image-not-found-tp27636263p27637052.html Sent from the FOP - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org - To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org
Re: [ERROR] Image not found
Thank you all. I found the answer for my prays. The answer were in dead on URIResolver. I just had to add this into my code to configure my FOUserAgent. (So easy, but so much difficult to find the solution) // configure foUserAgent as desired foUserAgent.setURIResolver(new URIResolver() { public Source resolve(String href, String base) throws TransformerException { return new StreamSource(getClass().getClassLoader ().getResourceAsStream(href)); } }); Thanks again. Best regards. Philippe Voncken wrote: With my SimpleUriResolver() you must use xsl as follow: fo:block fo:external-graphic src=url('logo.gif')/ /fo:block if logo.gif is in your classpath root element, it will work. Philippe 2010/2/18 Georg Datterl gdatt...@geneon.de Hi pjmorce, Assuming TstFOP.jar is on the server and found by your application server, what happens if you use fo:block fo:external-graphic src=url('file:TstFOP.jar!/img/logo.gif')/ /fo:block Mit freundlichen Grüßen Georg Datterl -- Kontakt -- Georg Datterl Geneon media solutions gmbh Gutenstetter Straße 8a 90449 Nürnberg HRB Nürnberg: 17193 Geschäftsführer: Yong-Harry Steiert Tel.: 0911/36 78 88 - 26 Fax: 0911/36 78 88 - 20 www.geneon.de Weitere Mitglieder der Willmy MediaGroup: IRS Integrated Realization Services GmbH:www.irs-nbg.de Willmy PrintMedia GmbH:www.willmy.de Willmy Consult Content GmbH: www.willmycc.de -Ursprüngliche Nachricht- Von: pjmorce [mailto:pjcarva...@gmail.com] Gesendet: Donnerstag, 18. Februar 2010 11:47 An: fop-users@xmlgraphics.apache.org Betreff: Re: [ERROR] Image not found I tried your suggestion: in the XSL I have now the following code and the problem remains: fo:block fo:external-graphic src=url('file:/img/logo.gif')/ /fo:block However, i also tried to put this and it worked: fo:block fo:external-graphic src=jar:file:///D:/eclipse_galileo/eclipse/TstFOP/TstFOP.jar!/img/logo.gif/ /fo:block It worked, but obvious reasons I cannot put this on the XSL that will be on production... :( Hi, It is more of a URL problem, try pass URL 'file:/img/logo.gif' instead of relative path. Thanks, Venkat. philippe voncken wrote: Hi, you must implementing the UriResolver and set your fopFactory with it. fopFactoy.setUriResolver() regards, Philippe -- View this message in context: http://old.nabble.com/-ERROR--Image-not-found-tp27636263p27637052.html Sent from the FOP - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org - To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org -- View this message in context: http://old.nabble.com/-ERROR--Image-not-found-tp27636263p27637247.html Sent from the FOP - Users mailing list archive at Nabble.com. - To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org