Page 1 of 1

Problem with fo:external-graphic

Posted: Thu May 18, 2006 12:30 pm
by imhotep
Hi,

I would like to insert an image in a PDF file with Fop 0.92.

i try this

<fo:block>
<fo:external-graphic src="logo.jpg"/>
</fo:block>

But i have this error :
May 18, 2006 11:38:00 AM org.apache.fop.fo.flow.ExternalGraphic bind
SEVERE: Image not available: logo.jpg

But the image is in the same folder as the xml and xsl file i use to create the PDF file.
Can someone help me ?

I try to have a look at fop.xconf to set basedir but i don't think that this file is read.
Where i have to place it ?

Thanks in advance.
Imhotep

Posted: Thu May 18, 2006 3:33 pm
by sorin_ristache
Hello,

Probably the logo.jpg file is not in the same folder as the XSL-FO file. Try the following example and make sure you copy the logo.jpg file in the same folder as the XSL-FO file and that it contains a JPEG image:

Code: Select all

<?xml version="1.0" encoding="iso-8859-1"?>
<fo:root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="my-page">
<fo:region-body margin="1in"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="my-page">
<fo:flow flow-name="xsl-region-body">
<fo:block>
<fo:external-graphic src="logo.jpg"/>
</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
When I apply FOP to this file I get a PDF file containing the JPEG image. I do not use the fop.xconf file (after I removed it the PDF file is generated correctly).

Regards,
Sorin

Posted: Thu May 18, 2006 3:42 pm
by imhotep
Sorry,

I try your example with FOP 0.92 using the servlet FOPServlet include in fop.jar, but the pdf file is blank, and the logo.jpg is in the same folder.

Can you give me an example of code that generate your pdf file.
I using fop with Tomcat. Is it a problem ?

Thanks in advance
Imhotep

Posted: Thu May 18, 2006 4:29 pm
by sorin_ristache
Hello,

I obtained the PDF by running FOP at the command line in the FOP install folder:

Code: Select all

fop.bat -fo test.fo -pdf test.pdf
I got the same result by applying FOP to the same FO file in <oXygen/>. If the above sample file does not work for you then the file path of the FO file must be set when the FOP servlet is called but I think this is a Tomcat question.

I hope that helps,
Sorin

Posted: Thu May 18, 2006 5:35 pm
by imhotep
It's works using the command line fop.bat .........
but using the servlet there is a classpath problem.
Indeed the url is :
http://localhost:8080/fop?fo=c:/temp/testimage.fo

the image logo.jpg is in the same folder, but i think that fop servlet doesn't know where.
Is there is a instruction to identify the classpath ?

Thanks in advance.

Imhotep

Posted: Fri May 19, 2006 6:53 am
by george
Is there is a instruction to identify the classpath ?
No, but you can get the current classloader and if it is an URLClassLoader then you may get the URLs it looks into, then you can get its parent and do the same until you get a null parent. This might give you information about what it is accessible through the classloaders at that point.

Best Regards,
George

Problem loading images in PDF with FOP

Posted: Wed Jul 19, 2006 12:37 pm
by devauk
Hi,

I want to include a GIF into a PDF, which is there in Websever location (/nova/global/images).

Following bits of code is implemented on both webpshere 5.0.1 and 6.0.0.1, images are displaying in webpshere 5.0.1 and but not in webpshere 6.0.0.1. I am using fop 0.20.5, cocoon 2.1, Xalan 2.5.1 and Xerces 2.4.0

<fo:block text-align="right" font-weight="bold" padding="10pt">
<fo:external-graphic src="url('{$domain}/nova/global/images/nissan-logo.gif')" />
</fo:block>

and

<fo:external-graphic>
<xsl:attribute name="src">url('<xsl:value-of select="$domain"/><xsl:value-of select="/page/generic/NSC-MODEL-XTND/NSC-MODEL-XTND-EBROCHURE-IMAGE" />')</xsl:attribute>
</fo:external-graphic>

and

<fo:external-graphic src="http://preprodweb1.xxxxx.co.uk/nova/glo ... n-logo.gif"/>


In the above code, value of domain is comming from XML (value is http://prepodweb1.xxxxx.co.uk) and value for /page/generic/NSC-MODEL-XTND/NSC-MODEL-XTND-EBROCHURE-IMAGE is /Media-Library/vehicles/e-brochure/br-micramc2005.jpg


Also implemented the suggestion, which I found in google search.
1) src="logo.jpg"
2) src="file:./logo.jpg"
3) src="file://./logo.jpg"
4) src="url('imagesrc')"

Is there any issue with Webpshere 6.0.0.1.

It would be extremely helpful for any suggestions.

Thanks & Regards,
Deva