Embedding Apache fop 2.1 in java servlet

拟墨画扇 提交于 2019-12-01 19:42:51

At the moment you are not using your configuration file, so the fonts are not configured and they are not embedded in the PDF output.

The URI parameter in the FopFactoryBuilder constructor is used to resolve relative URIs, not to load the configuration file.

As per embedding instructions, your code should have something similar to this:

import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.DefaultConfigurationBuilder;

...

DefaultConfigurationBuilder cfgBuilder = new DefaultConfigurationBuilder();
Configuration cfg = cfgBuilder.buildFromFile(new File("conf/conf.xml"));
FopFactoryBuilder fopFactoryBuilder = new FopFactoryBuilder(new File(".").toURI()).setConfiguration(cfg);
FopFactory fopFactory = fopFactoryBuilder.build();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!