Sorry but the FOP version was incorrect. That was the documentation
revision. I am using a very recent version.
On Wed, 2009-12-16 at 11:19 -0700, Gregory Buchenberger wrote:
> I'm embedding FOP version 627324 (trunk) in a Java application and am
> trying to register a font directory using the configuration file and
> the method fopFactory.setFontBaseURL(). The font directory is in the
> same parent directory as the jar file. The jar file directory
> basically looks like this (using indentation to represent folder
> hierarchy) :
>
> MyJar.jar
> conf/
> fopconf.xml
> xml/
> xslt/
> mystylesheet.xsl
> includes/
> lib/
> fop.jar
> fonts/
> dejavu-ttf-2.30/
> DejaVuSans.ttf
>
> The file conf/fopconf.xml contains the following:
>
> <?xml version="1.0"?>
> <fop version="1.0">
> <renderers>
> <renderer mime="application/pdf">
> <fonts>
> <directory recursive="true">./fonts</directory>
> </fonts>
> </renderer>
> </renderers>
> </fop>
>
> The class in my Java code that interacts with FOP contains this:
>
> public class XMLConverter {
>
> private Logger logger = Logger.getLogger(this.getClass().getName());
> private File xmlFile;
> private File xsltFile;
> private FopFactory fopFactory;
>
> public XMLConverter(File xmlfile, File xsltfile) {
> this.xmlFile = xmlfile;
> this.xsltFile = xsltfile;
> initFopFactory();
> }
>
> private void initFopFactory() {
> try {
> File jarFile = new File
> (MainFrame.class.getProtectionDomain().getCodeSource().getLocation().getPath().toString());
> String jarDir = jarFile.getParent();
> String xmlDir = xmlFile.getParent();
> this.fopFactory = FopFactory.newInstance();
> fopFactory.setUserConfig(new File(jarDir, "conf/fopconf.xml"));
> fopFactory.setFontBaseURL("file:///"+jarDir);
> fopFactory.setBaseURL("file:///"+xmlDir);
> } catch (Exception ex) {
> logger.severe(ex.getMessage());
> }
> }
>
> ..........
>
> The setUserConfig() and setBaseURL() methods seem to work as expected.
> I've tried using the following to my FOP configuration file as well.
>
> <font-base>../</font-base>
>
> The only way I can get it to work is by using an absolute path in the
> config , like so:
>
> <?xml version="1.0"?>
> <fop version="1.0">
> <renderers>
> <renderer mime="application/pdf">
> <fonts>
> <directory
> recursive="true">/home/greg/NetBeansProjects/NIMAS2PDF/dist/fonts</directory>
> </fonts>
> </renderer>
> </renderers>
> </fop>
>
> Have any of you any idea what stupid thing I am doing wrong here?
> While it's possible to obtain an absolute path via interaction with
> the user, I would prefer to store at least a base set of fonts within
> the jar directory that is installed with the application.
>
> Kind Regards,
>
> Gregory Buchenberger
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]