hi,
i can embed fonts via command-line to the file "fop.xml" and render a
pdf with special fonts.
"fop.xml"
<fop version="1.0">
<renderers>
<renderer mime="application/pdf">
<filterList>
<value>null</value>
</filterList>
<filterList type="image">
<value>flate</value>
<value>ascii-85</value>
</filterList>
<font-base>/tmp/</font-base>
<fonts>
<font metrics-url="testfont.xml" kerning="yes" embed-url="testfont.ttf">
<font-triplet name="testfont" style="normal" weight="normal"/>
</font>
</fonts>
</renderer>
</renderers>
<target-resolution>300</target-resolution>
</fop>
*is it also via java possible to safe the font-information to "fop.xml"
for later use?*
i tried this, but i don't know to save my changes back to a xml-file!
...
String fontname = "test1";
String filename = "test1.ttf";i
// set own configuation file:
try {
FontTriplet fontTriplet = new
FontTriplet(fontname,Font.STYLE_NORMAL, Font.WEIGHT_NORMAL);
List<FontTriplet> fontTriplets = new ArrayList<FontTriplet>();
fontTriplets.add(fontTriplet);
EmbedFontInfo nfont = new
EmbedFontInfo(filename.substring(0,datei.length()-3)+"xml", true,
fontTriplets, filename, fontname);
DefaultConfigurationBuilder cfgBuilder = new
DefaultConfigurationBuilder();
Configuration cfg = cfgBuilder.buildFromFile(new
File("/tmp/fop.xml"));
FopFactory fopFactory = FopFactory.newInstance();
fopFactory.setUserConfig(cfg);
fopFactory.getFontManager().setFontBaseURL"/tmp/");
fopFactory.getFontManager().getFontCache().addFont(nfont);
fopFactory.getFontManager().getFontCache().save();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
...
*how can i save my configuration?*