使用docx4j时的转换异常(从Docx到PDF)

时间:2014-03-18 13:18:03

标签: pdf-generation docx4j

我想知道为什么这段代码:

      String inputfilepath = "D:\\DFADFADSF";
      WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new java.io.File(inputfilepath + ".docx"));
      MainDocumentPart documentPart = wordMLPackage.getMainDocumentPart();            
      wordMLPackage.setFontMapper(new IdentityPlusMapper());
      FOSettings foSettings = Docx4J.createFOSettings();
      foSettings.setWmlPackage(wordMLPackage);
      String outputfilepath = "D:\\OUT_FontContent.pdf";
      OutputStream os = new java.io.FileOutputStream(outputfilepath);
      Docx4J.toPDF(wordMLPackage,os);

引发此异常:

org.docx4j.openpackaging.exceptions.Docx4JException: Exception exporting package
org.docx4j.openpackaging.exceptions.Docx4JException: Exception executing transformer: org.apache.fop.fo.ValidationException: "fo:flow" is missing child elements. Required content model: marker* (%block;)+

虽然有类似的帖子,但我还没有看到关于这个例外......

也许我应该添加aditional代码来配置转换......

0 个答案:

没有答案