on 2015 May 13 1:02 PM
Hi all,
I am using FOP to generate a PDF file. I need to use some custom fonts, so I followed this guide to tell FOP where on the disk to find them.
The guide works perfectly on a standalone FOP instance, while I am not able to replicate the same behavior on the Hybris embedded version, due to a problem with relative paths. It seems that no matter what I configure, I am not able to reach my fonts using a relative path, either to the Hybris bin dir, the fop configuration file dir, the fop lib dir, etc...
The Apache guide says:
Relative URIs for those properties are evaluated relative to the base URI of the configuration file. If the configuration is provided programmatically, the base URI can be set with FopFactory.setUserConfigBaseURI ; default is the current working directory.
I tried different configurations for the fopconfig.xml file; I also tried to customize the fop.config.xml property inside project.properties, with no luck.
The only working configuration is the following:
<fop version="1.0">
<strict-validation>false</strict-validation>
<renderers>
<renderer mime="application/pdf">
<fonts>
<directory>ABSOLUTE_PATH_TO_MY_HYBRIS_BIN_DIR/platform/ext/commons/resources/commons/config/fonts/</directory>
<autodetect/>
</fonts>
</renderer>
</renderers>
</fop>
But of course I don't want to use an absolute path.
Could someone help me?
Thank you Francesco
Ok, I found a possible solution: for some reason, the current working directory for FOP is somewhere two levels above the "platform" folder. I realized that because the following configuration works:
<fop version="1.0">
<strict-validation>false</strict-validation>
<renderers>
<renderer mime="application/pdf">
<fonts>
<directory recursive="true">../../</directory>
<autodetect/>
</fonts>
</renderer>
</renderers>
</fop>
After a little bit more investigation, I found the solution:
<fop version="1.0">
<strict-validation>false</strict-validation>
<renderers>
<renderer mime="application/pdf">
<fonts>
<directory>../../ext/commons/resources/commons/config/fonts/</directory>
<autodetect/>
</fonts>
</renderer>
</renderers>
</fop>
So basically, the "../../" brings you two levels under to the platform folder, then you can continue your path as you wish. What the CWD is remains a mystery... :-)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.