You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Jon Kofal <jo...@yahoo.com> on 2002/08/07 08:23:38 UTC

Embedded FOP in Servlet with Fonts, userconfig.xml in JAR/WAR

I want to use FOP 0.20.3 with my own fonts.

I have successflly run the org.apache.fop.fonts.apps.TTFReader and
created the XML font metrics files.

This all works fine when I give File path names in the userconfig.xml
like:

<font metrics-file="file://pathTo.xml" kerning="yes"
embed-file="pathTo.ttf">

and in my Servlet call the method:

            org.apache.fop.apps.Options options = new
org.apache.fop.apps.Options(new java.io.File("pathToUserconfig.xml"));

Now I want to do this with all the File objects as resources from the
JAR or WAR that contains the Servlet.

FOP seems heavy on java.io.File objects and I cannot seem to get this
to work having tried many abstractions on the naming of the File
objects.

Has anyone worked on and/or solved this problem?

Thanks,
Jon Kofal

__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com

Re: Embedded Fonts in FOP 0.20.3

Posted by Jon Kofal <jo...@yahoo.com>.
Problem solved.

I don't want to tie myself to a Servlet container, so placing the files
in TOMCAT/bin doesn't work.

What I did is put the userconfig.xml, and all my font.xml and font.dtd
files in my jar file.

My userconfig.xml has the base filenames of the .xml and .ttf files
(metrics-file="MyFont.xml" embed-file="MyFont.ttf").

I access the XML Elements at XPATH //font and add the value of the
javax.servlet.context.tempdir + a file.separator to the front of the
Attribute Value, adding a file:// to the font-metrics to match the
peculiar FOP protocol.  (I end up with
(metrics-file="file:///tempDir/MyFont.xml"
embed-file="/tempDir/MyFont.ttf").

I then read all the files from the jar (.xml and .ttf) and write them
to the javax.servlet.context.tempdir.

I write this userconfig.xml to the javax.servlet.context.tempdir.

I then instantiate a org.apache.fop.apps.Options with the just written
userconfig.xml.

This is a pain, but it works.

I'll recommend to the FOP developers to allow for Resources from the
JAR file, not just inflexible File objects.

Jon K



__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com

Re: Embedde

Posted by Balaji Loganathan <ba...@yahoo.com>.
Hi,
 Another hard try.. If u look at Velocity,their is an
examaple SampleServlet2.java which loads the
neccessary templates(.vm file) from jar file located
under lib directroy,mey be that will give u an idea on
how to code to loading file objects from jar files.

Regards
Balaji


http://digital.yahoo.com.au - Yahoo! Digital How To
- Get the best out of your PC!

Re: Embedded FOP in Servlet with Fonts, userconfig.xml in JAR/WAR

Posted by Balaji Loganathan <ba...@yahoo.com>.
Hi,
 If you are using Tomcat, Why don't u try to put all
the necessary files in bin/directory and give a try.
 Under bin directroy put ur
pathTo.xml,PathTo.ttf,pathToUserconfig.xml,*.xsl,*.fo
files.. with relative path configurations..
 Just give a try.. 
Regards
Balaji


 
 --- Jon Kofal <jo...@yahoo.com> wrote: > I want to
use FOP 0.20.3 with my own fonts.
> 
> I have successflly run the
> org.apache.fop.fonts.apps.TTFReader and
> created the XML font metrics files.
> 
> This all works fine when I give File path names in
> the userconfig.xml
> like:
> 
> <font metrics-file="file://pathTo.xml" kerning="yes"
> embed-file="pathTo.ttf">
> 
> and in my Servlet call the method:
> 
>             org.apache.fop.apps.Options options =
> new
> org.apache.fop.apps.Options(new
> java.io.File("pathToUserconfig.xml"));
> 
> Now I want to do this with all the File objects as
> resources from the
> JAR or WAR that contains the Servlet.
> 
> FOP seems heavy on java.io.File objects and I cannot
> seem to get this
> to work having tried many abstractions on the naming
> of the File
> objects.
> 
> Has anyone worked on and/or solved this problem?
> 
> Thanks,
> Jon Kofal
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Health - Feel better, live better
> http://health.yahoo.com 

http://digital.yahoo.com.au - Yahoo! Digital How To
- Get the best out of your PC!