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 valuenull/value /filterList filterList type=image valueflate/value valueascii-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-resolution300/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); ListFontTriplet fontTriplets = new ArrayListFontTriplet(); 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?*
RE: manipulate fop configuration file via java
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:ingo.pe...@ip-software.de] Sent: Thursday, March 10, 2011 8:13 AM To: fop-users@xmlgraphics.apache.org 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 valuenull/value /filterList filterList type=image valueflate/value valueascii-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-resolution300/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); ListFontTriplet fontTriplets = new ArrayListFontTriplet(); 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?
Re: manipulate fop configuration file via java
Hi, Correct me if I'm wrong but I think you're trying to serialize the data that you configure progammatically. If so, but I don't think that feature currently exists in FOP (or if it does, I haven't come across it). If you wish to set and save config settings, you could use the various XML DOM libraries out there to create a custom fop.xconf. That will allow you to serialize any changes you make and you can make changes at run-time. There maybe another way of doing this, but short of creating your own serialization format (which in fairness wouldn't be very difficult), that's the only way I can think of. I may however have the wrong end of the stick here, if so, my apologies. Mehdi On 10 March 2011 15:34, Eric Douglas edoug...@blockhouse.com wrote: 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:ingo.pe...@ip-software.de] Sent: Thursday, March 10, 2011 8:13 AM To: fop-users@xmlgraphics.apache.org 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 valuenull/value /filterList filterList type=image valueflate/value valueascii-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-resolution300/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); ListFontTriplet fontTriplets = new ArrayListFontTriplet(); 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? - To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org
RE: manipulate fop configuration file via java
I'm not sure what you're talking about here, but FOP is not serializable, and the input and output is all serializable. -Original Message- From: mehdi houshmand [mailto:med1...@gmail.com] Sent: Thursday, March 10, 2011 10:44 AM To: fop-users@xmlgraphics.apache.org Subject: Re: manipulate fop configuration file via java Hi, Correct me if I'm wrong but I think you're trying to serialize the data that you configure progammatically. If so, but I don't think that feature currently exists in FOP (or if it does, I haven't come across it). If you wish to set and save config settings, you could use the various XML DOM libraries out there to create a custom fop.xconf. That will allow you to serialize any changes you make and you can make changes at run-time. There maybe another way of doing this, but short of creating your own serialization format (which in fairness wouldn't be very difficult), that's the only way I can think of. I may however have the wrong end of the stick here, if so, my apologies. Mehdi On 10 March 2011 15:34, Eric Douglas edoug...@blockhouse.com wrote: 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:ingo.pe...@ip-software.de] Sent: Thursday, March 10, 2011 8:13 AM To: fop-users@xmlgraphics.apache.org 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 valuenull/value /filterList filterList type=image valueflate/value valueascii-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-resolution300/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); ListFontTriplet fontTriplets = new ArrayListFontTriplet(); 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? - To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org - To unsubscribe, e-mail: fop-users-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-users-h...@xmlgraphics.apache.org