You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Stephan Kassanke <ka...@upb.de> on 2001/04/12 09:52:55 UTC

Relative URIs and images [Was:Different encoding results in running FOP from the commandline or embedded in an applet]

Kelly, thanks for your help. It worked, i get the text including umlauts and
accents in PDF. However, one problem is still unresolved. In the XML file, i
have references to images with a relative URI.

		<paragraph>
			<image type="image/gif" uri="./images/or_model.gif"/>
		</paragraph>

In the style sheet an fo:external graphic is used:

	<xsl:template match="image">
 		 <fo:external-graphic src="file:{@uri}"/>
	</xsl:template>

Similar to the previous situation, this combination of data and style works
when called from the commandline but fop cannot find the graphic when
embedded.

I get the follwing error:

using renderer org.apache.fop.render.pdf.PDFRenderer
using element mapping org.apache.fop.fo.StandardElementMapping
using element mapping org.apache.fop.svg.SVGElementMapping
using element mapping org.apache.fop.extensions.ExtensionElementMapping
using property list mapping org.apache.fop.fo.StandardPropertyListMapping
using property list mapping org.apache.fop.svg.SVGPropertyListMapping
using property list mapping
org.apache.fop.extensions.ExtensionPropertyListMappi
ng
building formatting object tree
setting up fonts
formatting FOs into areas
 [1Error while creating area : Error while recovering Image Informations
(file:.
/images/or_model.gif) : .\images\or_model.gif (Das System kann den
angegebenen P
fad nicht finden)
]
rendering areas to PDF
writing out PDF

I read in a previous post that this was a problem in fop 0.16 and a
configuration file was included to resolve this. Do I have to make the image
"context" known to fop via this configuration file? I am using fop 0.17 by
the way. is this a known issue?

Thanks,
Stephan

--------------
Stephan Kassanke, University of Paderborn, Decision Support & OR Lab, Room
N5.125, Warburger Straße 100, 33095 Paderborn, Germany, phone: +49 (0)5251
602416, fax:   +49 (0)5251 603542, mobile:+49 (0)171 8984868, mail:
kass@uni-paderborn.de, ICQ:   16285877
work: 	http://dsor.uni-paderborn.de
project:	http://www.or-world.com
private:	http://www.kassanke.de


-----Ursprüngliche Nachricht-----
Von: Kelly Campbell [mailto:camk@merlot.channelpoint.com]
Gesendet: Samstag, 31. März 2001 21:54
An: fop-dev@xml.apache.org
Betreff: Re: Different encoding results in running FOP from the
commandline or embedded in an applet


Stephan, you might want to give an plain Stream instead of a Reader. This
should allow Xerces to read the fo file in with the encoding it specifies
instead of the default encoding which is probably what the Reader is
doing.

Or better yet, since you have a File, just pass it's path to the
InputSource constructor, and that lets Xerces read it in however it needs
to, plus gives it a SystemID in case something needs to be resolved
relative to the file (like the DTD).

-Kelly

On Thu, Mar 29, 2001 at 11:32:46AM +0200, Stephan Kassanke wrote:
> Hi Kelly,
>
> Thanks for the quick response. I am giving FOP a reader for the file. The
> sample code is below.
>
> Stephan
>
> /**
>  * Default constructor.
>  */
>   public XmlToPdf() {
>   }
>
>  /**
>  * Constructor
>  * @param xmlFile XML source file.
>  * @param xslFile XSL source file.
>  */
>   public XmlToPdf(File xmlFile, File xslFile) {
>     this.xmlFile = xmlFile;
>     this.xslFile = xslFile;
>   }
>
> /**
>  * Creates a PDF file from a XML and a XSL file.
>  * Currently there ins an encoding problem when you try to save the XSLT
> result
>  * in a file therefore the result is stored in a StringWriter object (pay
>  * attention to memory limitations).
>  *
>  * @exception java.net.MalformedURLException If an error occurred while
> converting a filepath to an URL.
>  * @exception java.io.IOException If the specified file is corrupt or does
> not exist.
>  * @exception org.xml.sax.SAXException If the parsing process can not
finish
> correct.
>  * @exception javax.xml.transform.TransformerConfigurationException If an
> error occured while configuring the transformer.
>  * @exception javax.xml.transform.TransformerException If an error
occurred
> while creating the temporary FO file.
>  * @exception org.apache.fop.apps.FOPException If an error occurred while
> creating the PDF file.
>  */
>   public void doTransform() throws TransformerException,
> TransformerConfigurationException,
>                                    SAXException, FileNotFoundException,
>                                    FOPException, IOException{
>       String target = null;
>
>       // prepare files
>       URL url1 = xmlFile.toURL();
>       URL url2 = xslFile.toURL();
>       target =
xmlFile.getPath().substring(0,xmlFile.getPath().length()-3);
>
>       // Perform the transformation.
> 	TransformerFactory tFactory = TransformerFactory.newInstance();
> 	Transformer transformer = tFactory.newTransformer(new
> StreamSource(url2.toString()));
>         FileOutputStream foStream = new FileOutputStream(target+"fo");
>         transformer.transform(new StreamSource(url1.toString()),
>                               new StreamResult(foStream));
>         foStream.close();
>
>       // prepare reader
>       Reader reader = new FileReader(target+"fo");
>
>       // create XML reader
>       XMLReader parser = (XMLReader) new SAXParser();
>
>       // setting the parser features
>       parser.setFeature("http://xml.org/sax/features/namespace-prefixes",
> true);
>
>       //get version
>       String version = Version.getVersion();
>
>       //set Driver methods to start Fop processing
>       Driver driver = new Driver();
>       driver.setBaseDir(xmlFile.getPath());
>       driver.setRenderer("org.apache.fop.render.pdf.PDFRenderer",
version);
>
driver.addElementMapping("org.apache.fop.fo.StandardElementMapping");
>       driver.addElementMapping("org.apache.fop.svg.SVGElementMapping");
>
> driver.addPropertyList("org.apache.fop.fo.StandardPropertyListMapping");
>       driver.addPropertyList("org.apache.fop.svg.SVGPropertyListMapping");
>       OutputStream stream = new BufferedOutputStream(new
> FileOutputStream(target+"pdf"));
>       driver.setOutputStream(stream);
>       driver.buildFOTree(parser, new InputSource(reader));
>       reader.close();
>       driver.format();
>       driver.render();
>       new File(target+"fo").delete();
>   }
> }
>
> --------------
> Stephan Kassanke, University of Paderborn, Decision Support & OR Lab, Room
> N5.125, Warburger Straße 100, 33095 Paderborn, Germany, phone: +49 (0)5251
> 602416, fax:   +49 (0)5251 603542, mobile:+49 (0)171 8984868, mail:
> kass@uni-paderborn.de, ICQ:   16285877
> work: 	http://dsor.uni-paderborn.de
> private:	http://www.kassanke.de
>
>
> -----Ursprüngliche Nachricht-----
> Von: Kelly Campbell [mailto:camk@merlot.channelpoint.com]
> Gesendet: Mittwoch, 28. März 2001 22:12
> An: fop-dev@xml.apache.org
> Betreff: Re: Different encoding results in running FOP from the
> commandline or embedded in an applet
>
>
> How is your application passing the file to FOP? is it just giving the
> filename and letting FOP read it in, or is it giving FOP a Reader for the
> file? Can you send an example of your code?
>
> -Kelly
>
> On Wed, Mar 28, 2001 at 06:17:13PM +0200, Stephan Kassanke wrote:
> > hi,
> >
> > i try to embed fop 0.17 in a java application and it all works fine,
> except
> > for German umlauts which are included in the source XML file. The
encoding
> > of the XML source is UFT-8 and the strange phenomenon I experience is
that
> > the resulting PDF documents differ. The version which is created from a
> > commandline call generates the expected pdf result with umlauts. The
> version
> > created from my application (which does exactly the same method calls)
> > differs: The Umlauts are gone and there are signs such as "ü" instead
of
> an
> > "ü" (umlaut u).
> >
> > I did a diff on both files and got the following differences
> >
> > #... SNIP here
> > /Name /F12
> > /BaseFont /Courier-BoldOblique
> > /Encoding /WinAnsiEncoding >>
> > endobj
> > 19 0 obj
> >
>
?????????????????????operations_research-commandline.pdf????????????????????
> > ????
> > << /Length 1676 /Filter [ /ASCII85Decode /FlateDecode ]
>
  -------------------------------------------------------------------------
> --
> > ---
> > << /Length 1685 /Filter [ /ASCII85Decode /FlateDecode ]
> >
>
?????????????????????operations_research.pdf????????????????????????????????
> > ????
> >  >>
> > stream
> >
>
?????????????????????operations_research-commandline.pdf????????????????????
> > ????
> >
>
GasIh>Ar7S'RnB3csm-qWcb`"[r,p,%4r2<?=2i'TWBB-LdZM6A[h[34/=9ge.aG7Jp\XNahr2O0
> > :SF?
>
  -------------------------------------------------------------------------
> --
> > ---
> >
>
GasIhgMZ%0&:Ml+kV3*I`Oah$[VZXnM[^:Em_71>6!5G#Ld\g"AafK]98\s*.bZc]K$<1m3')->n
> > <_D?
> >
>
?????????????????????operations_research.pdf????????????????????????????????
> > ????
> > endstream
> > endobj
> > 20 0 obj
> > << /Type /Page
> > /Parent 2 0 R
> > /MediaBox [ 0 0 596 843 ]
> > /Resources 4 0 R
> > /Contents 19 0 R
> > >>
> > #... SNIP here
> >
> > The source files were encoded in UTF-8. The /Encoding in BOTH PDF files
> > reads "/WinAnsiEncoding". The next point is that the content with
respect
> to
> > non ascii chars seems to be mangled during XSL transformation. is tis a
> > problem of fop or xalan? Can anybody give me a hint on what I am doing
> > wrong? Any help is greatly appreciated.
> >
> > Stephan
> >
> > --------------
> > Stephan Kassanke, University of Paderborn, Decision Support & OR Lab,
Room
> > N5.125, Warburger Straße 100, 33095 Paderborn, Germany, phone: +49
(0)5251
> > 602416, fax:   +49 (0)5251 603542, mobile:+49 (0)171 8984868, mail:
> > kass@uni-paderborn.de, ICQ:   16285877
> > work: 	http://dsor.uni-paderborn.de
> > private:	http://www.kassanke.de
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
> > For additional commands, email: fop-dev-help@xml.apache.org
>
> --
> Kelly A. Campbell              Software Engineer
> <ca...@merlotxml.org>           ChannelPoint, Inc.
> <ca...@channelpoint.com>        Colorado Springs, Co.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
> For additional commands, email: fop-dev-help@xml.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
> For additional commands, email: fop-dev-help@xml.apache.org

--
Kelly A. Campbell              Software Engineer
<ca...@merlotxml.org>           ChannelPoint, Inc.
<ca...@channelpoint.com>        Colorado Springs, Co.

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org


AW: Relative URIs and images [Was:Different encoding results in running FOP from the commandline or embedded in an applet]

Posted by Stephan Kassanke <ka...@upb.de>.
Thierry,

I use JDK 1.3 and it works perfectly on the command line. the problem is
that embedded in a JAVA application, the image is not found. Is the relative
adressing of images a known problem in fop 0.17?

Stephan

--------------
Stephan Kassanke, University of Paderborn, Decision Support & OR Lab, Room
N5.125, Warburger Stra?e 100, 33095 Paderborn, Germany, phone: +49 (0)5251
602416, fax:   +49 (0)5251 603542, mobile:+49 (0)171 8984868, mail:
kass@uni-paderborn.de, ICQ:   16285877
work: 	http://dsor.uni-paderborn.de
project:	http://www.or-world.com
private:	http://www.kassanke.de


-----Ursprungliche Nachricht-----
Von: Thierry SAURA [mailto:Thierry.Saura@renault.fr]
Gesendet: Donnerstag, 12. April 2001 10:29
An: fop-dev@xml.apache.org
Betreff: Relative URIs and images [Was:Different encoding results in
running FOP from the commandline or embedded in an applet]



       Do you use JDK 1.1 ? I found a problem with URL class when you use
a relative file URL like "file:../graphics/linux.jpg"
there is no problem under JDK 1.2 ...

Thierry.


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org


Relative URIs and images [Was:Different encoding results in running FOP from the commandline or embedded in an applet]

Posted by Thierry SAURA <Th...@renault.fr>.
       Do you use JDK 1.1 ? I found a problem with URL class when you use
a relative file URL like "file:../graphics/linux.jpg"
there is no problem under JDK 1.2 ...

Thierry.


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-dev-unsubscribe@xml.apache.org
For additional commands, email: fop-dev-help@xml.apache.org