I'm building an application which reads in a docx template, modifies it, and then writes the modified docx file out. All that works fine. However, I also need to export it to pdf which is where the proverbial "wheels come off". I am using Mac OS X El Capitan and JBoss Developer Studio 9. The problem seems to involve fonts but I'm not sure what. One message that logs out is to delete the fop-font.cache but I'm not sure where it is. Any help is much appreciated. More info below:
I am trying to use a template I found here https://github.com/plutext/docx4j/blob/ ... utPDF.java
However, the first problem I find is that I get a NoClassDefFoundError when I try to set the fontMapper. See partial output below:
Mapper fontMapper = new IdentityPlusMapper();
wordMLPackage.setFontMapper(fontMapper);
[main] INFO org.docx4j.fonts.RunFontSelector - theme font for lang org.docx4j.wml.CTLanguage@63c5b63a is null, but we don't have that
[main] WARN org.docx4j.openpackaging.parts.ThemePart - Empty typeface in font for MINOR_EAST_ASIA
[main] INFO org.docx4j.fonts.RunFontSelector - theme font for lang org.docx4j.wml.CTLanguage@63c5b63a is null, but we don't have that
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/cache/CacheLoader
at org.docx4j.fonts.RunFontSelector.unicodeRangeToFont(RunFontSelector.java:818)
at org.docx4j.fonts.RunFontSelector.fontSelector(RunFontSelector.java:583)
at org.docx4j.fonts.RunFontSelector.fontSelector(RunFontSelector.java:316)
at org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart$FontAndStyleFinder.apply(MainDocumentPart.java:521)
at org.docx4j.TraversalUtil$CallbackImpl.walkJAXBElements(TraversalUtil.java:159)
at org.docx4j.TraversalUtil$CallbackImpl.walkJAXBElements(TraversalUtil.java:162)
at org.docx4j.TraversalUtil$CallbackImpl.walkJAXBElements(TraversalUtil.java:162)
at org.docx4j.TraversalUtil.<init>(TraversalUtil.java:209)
at org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart.fontsInUse(MainDocumentPart.java:245)
at org.docx4j.openpackaging.packages.WordprocessingMLPackage.setFontMapper(WordprocessingMLPackage.java:337)
at org.docx4j.openpackaging.packages.WordprocessingMLPackage.setFontMapper(WordprocessingMLPackage.java:299)[/color]
Now if I comment that out and attempt to generate the pdf document I get a very similar problem when I execute this line:
Docx4J.toFO(foSettings, os, Docx4J.FLAG_EXPORT_PREFER_XSL);
See below:
[main] WARN org.docx4j.openpackaging.parts.ThemePart - Empty typeface in font for MINOR_EAST_ASIA
[main] INFO org.docx4j.fonts.RunFontSelector - theme font for lang org.docx4j.wml.CTLanguage@2adc9300 is null, but we don't have that
[main] WARN org.docx4j.openpackaging.parts.ThemePart - Empty typeface in font for MINOR_EAST_ASIA
[main] INFO org.docx4j.fonts.RunFontSelector - theme font for lang org.docx4j.wml.CTLanguage@2adc9300 is null, but we don't have that
Exception in thread "main" java.lang.NoClassDefFoundError: com/google/common/cache/CacheLoader
at org.docx4j.fonts.RunFontSelector.unicodeRangeToFont(RunFontSelector.java:818)
at org.docx4j.fonts.RunFontSelector.fontSelector(RunFontSelector.java:583)
at org.docx4j.fonts.RunFontSelector.fontSelector(RunFontSelector.java:316)
at org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart$FontAndStyleFinder.apply(MainDocumentPart.java:521)