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

柔情痞子 提交于 2019-12-01 18:40:44

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.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!