BIRT: pdf emitter, load/use fonts from relative path or from jar files

前端 未结 2 558
心在旅途
心在旅途 2021-01-13 05:51

I use BIRT since early days and still have riddles regarding PDF emitter.

Short story: Can I configure fontsConfig.xml to load fonts from relative

相关标签:
2条回答
  • 2021-01-13 06:00

    There is a way to have fonts on a relative path to be used in Birt.

    What you need to do is copy the fonts to a location in your Web Application. Mine was in : C:\\src\main\webapp\Reports

    Now in the application, use the following command to register the fonts from the above mentioned location.

    FontFactory.registerDirectory( scContext.getRealPath("/Reports") );
    

    This will register the font.

    Tested on Birt 4.3 through Spring MVC

    0 讨论(0)
  • 2021-01-13 06:18

    With some BIRT versions, you can use a SystemProperty "birt.font.dirs". This overrides the fontsConfig.xml.

    Well, this once worked, but obviously it was removed from the BIRT source code later.

    Now you can call something like

    EngineConfig engineConfig = new EngineConfig();
    URL fontsConfigurationURL = new URL("file:///path/to/my/fontsConfig.xml");
    engineConfig.setFontConfig(fontsConfigurationURL);
    
    Platform.startup(engineConfig);
    

    This allows you to supply BIRT with a customized version of fontsConfig.xml without poking around in the JARs.

    Tested with BIRT 4.3.0.

    0 讨论(0)
提交回复
热议问题