Hello,
when converting docx to PDF, I get this error in my log:
Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.docx4j.fonts.GlyphCheck
at org.docx4j.fonts.RunFontSelector.unicodeRangeToFont(RunFontSelector.java:847)
at org.docx4j.fonts.RunFontSelector.fontSelector(RunFontSelector.java:588)
at org.docx4j.fonts.RunFontSelector.fontSelector(RunFontSelector.java:316)
at org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart$FontAndStyleFinder.apply(MainDocumentPart.java:533)
at org.docx4j.TraversalUtil$CallbackImpl.walkJAXBElements(TraversalUtil.java:164)
at org.docx4j.TraversalUtil$CallbackImpl.walkJAXBElements(TraversalUtil.java:167)
at org.docx4j.TraversalUtil$CallbackImpl.walkJAXBElements(TraversalUtil.java:167)
at org.docx4j.TraversalUtil$CallbackImpl.walkJAXBElements(TraversalUtil.java:167)
at org.docx4j.TraversalUtil$CallbackImpl.walkJAXBElements(TraversalUtil.java:167)
at org.docx4j.TraversalUtil$CallbackImpl.walkJAXBElements(TraversalUtil.java:167)
at org.docx4j.TraversalUtil$CallbackImpl.walkJAXBElements(TraversalUtil.java:167)
at org.docx4j.TraversalUtil.<init>(TraversalUtil.java:214)
at org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart.fontsInUse(MainDocumentPart.java:256)
at org.docx4j.openpackaging.packages.WordprocessingMLPackage.setFontMapper(WordprocessingMLPackage.java:347)
at org.docx4j.openpackaging.packages.WordprocessingMLPackage.setFontMapper(WordprocessingMLPackage.java:309)
at models.export.word.WordExporter.export(WordExporter.java:224)
at models.export.word.WordExporter.exportClassPath(WordExporter.java:163)
at service.lsjzjn.SavePdfService.saveInfoPdf(SavePdfService.java:68)
at controllers.lsjzjn.RecordResultMgr.downRecordTable(RecordResultMgr.java:198)
at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:527)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:478)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:454)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:449)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:161)
... 1 more
And my code like this:
Mapper fontMapper = new IdentityPlusMapper();
wordMLPackage.setFontMapper(fontMapper);
fontMapper.put("隶书", PhysicalFonts.get("LiSu"));
fontMapper.put("宋体", PhysicalFonts.get("SimSun"));
fontMapper.put("微软雅黑", PhysicalFonts.get("Microsoft Yahei"));
fontMapper.put("黑体", PhysicalFonts.get("SimHei"));
fontMapper.put("楷体", PhysicalFonts.get("KaiTi"));
fontMapper.put("新宋体", PhysicalFonts.get("NSimSun"));
fontMapper.put("华文行楷", PhysicalFonts.get("STXingkai"));
fontMapper.put("华文仿宋", PhysicalFonts.get("STFangsong"));
fontMapper.put("宋体扩展", PhysicalFonts.get("simsun-extB"));
fontMapper.put("仿宋", PhysicalFonts.get("FangSong"));
fontMapper.put("仿宋_GB2312", PhysicalFonts.get("FangSong_GB2312"));
fontMapper.put("幼圆", PhysicalFonts.get("YouYuan"));
fontMapper.put("华文宋体", PhysicalFonts.get("STSong"));
fontMapper.put("华文中宋", PhysicalFonts.get("STZhongsong"));
FOSettings foSettings = Docx4J.createFOSettings();
foSettings.setWmlPackage(wordMLPackage);
org.docx4j.Docx4J.toFO(foSettings, stream, Docx4J.FLAG_EXPORT_PREFER_XSL);
Appreciate for any help.