What are you trying to save? What you're talking about here is an either or. You can load font information using the configuration file or you can load them straight from the ttf with embedded code. If you're using the embedded code you don't need the configuration file for fonts. You also don't need a metrics file anymore.
________________________________ From: ingo peter [mailto:[email protected]] Sent: Thursday, March 10, 2011 8:13 AM To: [email protected] Subject: manipulate fop configuration file via java 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?
