BIRT:pdf发射器,从相对路径或从jar文件加载/使用字体 [英] BIRT: pdf emitter, load/use fonts from relative path or from jar files

查看:263
本文介绍了BIRT:pdf发射器,从相对路径或从jar文件加载/使用字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我早期使用BIRT,仍然有关于PDF发射器的谜语。

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

短篇小说
我可以配置fontsConfig.xml从相对路径还是从jar加载字体?

Short story: Can I configure fontsConfig.xml to load fonts from relative path or from jars?

长篇故事:
我们正在使用FOP和BIRT在我们的Web应用程序中生成PDF。在图书馆之间分享字体会很好。不幸的是,我找不到一个方法来做BIRT 2.3.1

Long story: We are using both FOP and BIRT for generating PDF in our web application. It would be nice to share fonts between libraries. Unfortunately, I can't find a way to do it with BIRT 2.3.1

邪恶的根源是fontsConfig.xml
如果我配置如图所示下面它工作正常:

The root of evil is fontsConfig.xml If I configure it like shown below it works fine:

<font-paths>
<path path="fonts"/>
</font-paths>

但路径不允许我使用相对路径不是classpath(或者我找不到适当的方式配置它)。
config1和config2都不起作用。

But path doesn't allow me using neither relative paths not classpath (or I can't find an appropriate way how to configure it). Neither config1 nor config2 works.

配置1:

<font-paths>
<path path="../fonts"/>
</font-paths>

Config2:

<font-paths>
<path path="classpath:fonts"/>
</font-paths>

任何想法都将不胜感激。

Any thoughts will be appreciated.

推荐答案

使用一些BIRT版本,您可以使用SystemPropertybirt.font.dirs。这覆盖了fontsConfig.xml。

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

嗯,这一次工作,但显然是从BIRT源代码中删除。

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

现在您可以调用类似于

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

Platform.startup(engineConfig);

这允许您为BIRT提供fontsConfig.xml的自定义版本,而不会在JAR中出现。

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

使用BIRT 4.3.0进行测试。

Tested with BIRT 4.3.0.

这篇关于BIRT:pdf发射器,从相对路径或从jar文件加载/使用字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆