Page 1 of 1

Docx4j fop configuration using servlet-context path

PostPosted: Thu Apr 30, 2015 5:18 pm
by mmshabeer
I'm using Docx4j(3.2.0) to create pdf.

Embedding font using fop.xconf

Code: Select all
<base>./</base>
<font metrics-url="servlet-context:/fonts/DejaVuSerif-Bold.xml" embed-url="servlet-context:/WEB-INF/fonts/DejaVuSerif-Bold.ttf" kerning="yes">
  <font-triplet name="DejaVuSerif-Bold" style="normal" weight="normal" />
</font>


and setting through api

Code: Select all
FOSettings foSettings = Docx4J.createFOSettings();
foSettings.setWmlPackage(wordMLPackage);
ClassPathResource cpr = new ClassPathResource("fop.conf");
InputStream inputStream = cpr.getInputStream();
StringWriter writer = new StringWriter();
IOUtils.copy(inputStream, writer, "UTF-8");
String conf = writer.toString();


yields following exception:

Exception setting up result for fo transformation: Failed to resolve font with embed-url 'servlet-context:/WEB-INF/fonts/DejaVuSerif-Bold.ttf'.

Is there a way I can set user agent through fosettings or any other parameters I need to set in config(fop), so that fonts need to embedded on pdf picked up from context path?

Using Fop(1.1)

Thanks.

Re: Docx4j fop configuration using servlet-context path

PostPosted: Fri May 01, 2015 9:54 am
by jason
Duplicate/cross-post of http://stackoverflow.com/questions/2994 ... ntext-path

Please don't do that.