xmlgraphics-fop-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Venkat Reddy <vanukuri.ven...@googlemail.com>
Subject Re: Relative path to font directory
Date Thu, 17 Dec 2009 12:07:34 GMT
Hi,

Have you tried the following?

<!-- Base URL for resolving relative URLs -->
<base>./</base>
<!-- Font Base URL for resolving relative font URLs -->
<font-base>./</font-base>

Source:
http://xmlgraphics.apache.org/fop/trunk/configuration.html#general-elements

Thanks,
Venkat.



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: fop-users-unsubscribe@xmlgraphics.apache.org
> For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org
>
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: fop-users-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-users-help@xmlgraphics.apache.org


Mime
View raw message