After upgrading from FOP 1.1 to FOP 2.0 my custom fonts are no longer being
recognized. I am using the FOPServlet.java code to ant build my fop.war file.
In order to get my fonts to work in version 1.1 I had to make the following
change:
/**
* This method is called right after the FopFactory is instantiated and can
be overridden
* by subclasses to perform additional configuration.
*/
protected void configureFopFactory() {
try {
fopFactory.setUserConfig(new File("/conf/fop.xconf"));
} catch (SAXException e) {
System.out.println(e);
} catch (IOException e) {
System.out.println(e);
}
}
I’ve read in the release notes for 2.0 that setUserConfig is retired and I have
tried to understand how to implement the new method. Can I get some guidance
here? When I put the suggested code in, I am getting java compile errors on the
FopFactoryBuilder symbol not recognized. Is there a working modified
FOPServlet.java that has the points to an external config somewhere?
https://xmlgraphics.apache.org/fop/2.0/upgrading.html
Here is the code from the above upgrade page I am struggling with:
File xconf = new File("fop.xconf");
FopConfParser parser = new FopConfParser(xconf); //parsing configuration
FopFactoryBuilder builder = parser.getFopFactoryBuilder(); //building the
factory with the user options
FOPFactory fopFactory = builder.build();
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out)
Is there a way to set the ant build script to read my config file when building
the war file (without having to modify the standard java code)?
Here is my fop.xconf in \conf:
<?xml version="1.0"?>
<fop>
<renderers>
<renderer mime="application/pdf">
<fonts>
<font kerning="yes"
embed-url="file:///C:/windows/fonts/arial.ttf">
<font-triplet name="Arial" style="normal"
weight="normal"/>
</font>
<font kerning="yes"
embed-url="file:///C:/windows/fonts/Mon821Rm.ttf">
<font-triplet name="Monospac821" style="normal"
weight="normal"/>
</font>
<font kerning="yes"
embed-url="file:///C:/windows/fonts/Mon821Bd.ttf">
<font-triplet name="Monospac821" style="normal"
weight="bold"/>
</font>
</fonts>
</renderer>
</renderers>
</fop>
Thanks!
Paul