- Code: Select all
[2016-09-25 22:16:14.539] The contents of fo:region-body on page 4 exceed its viewport by 21238 millipoints. (See position 1:448)
[2016-09-25 22:16:14.539] The contents of fo:region-body on page 3 exceed its viewport by 21238 millipoints. (See position 1:448)
[2016-09-25 22:16:14.540] The contents of fo:region-body on page 2 exceed its viewport by 21238 millipoints. (See position 1:448)
[2016-09-25 22:16:14.540] The contents of fo:region-body on page 1 exceed its viewport by 21238 millipoints. (See position 1:448)
[2016-09-25 22:16:14.549] Using repackaged ToXMLStream
[2016-09-25 22:16:14.549] Using repackaged ToXMLStream
[2016-09-25 22:16:14.557] No theme part - default to Calibri
[2016-09-25 22:16:14.571] Exception exporting package
org.docx4j.openpackaging.exceptions.Docx4JException: Exception writing Document to OutputStream: org.apache.fop.fo.ValidationException: "fo:flow" is missing child elements. Required content model: marker* (%block;)+ (See position 1:958)
at org.docx4j.utils.XmlSerializerUtil.serialize(XmlSerializerUtil.java:31)
at org.docx4j.convert.out.fo.renderers.FORendererApacheFOP.render(FORendererApacheFOP.java:209)
at org.docx4j.convert.out.fo.renderers.FORendererApacheFOP.render(FORendererApacheFOP.java:159)
at org.docx4j.convert.out.fo.AbstractFOExporter.postprocess(AbstractFOExporter.java:168)
at org.docx4j.convert.out.fo.AbstractFOExporter.postprocess(AbstractFOExporter.java:47)
at org.docx4j.convert.out.common.AbstractExporter.export(AbstractExporter.java:82)
at org.docx4j.Docx4J.toFO(Docx4J.java:568)
Here is my test code:
- Code: Select all
String regex = null;
PhysicalFonts.setRegex(regex);
WordprocessingMLPackage wordMLPackage;
InputStream is = new ByteArrayInputStream(document);
ByteArrayOutputStream baos = null;
try {
wordMLPackage = WordprocessingMLPackage.load(is);
wordMLPackage = wordMLPackage.createPackage(PageSizePaper.A5, false);
FieldUpdater updater = new FieldUpdater(wordMLPackage);
updater.update(true);
Mapper fontMapper = new IdentityPlusMapper();
wordMLPackage.setFontMapper(fontMapper);
FOSettings foSettings = Docx4J.createFOSettings();
foSettings.setWmlPackage(wordMLPackage);
/*OutputStream os = new java.io.FileOutputStream("C:/test.pdf");
Docx4J.toFO(foSettings, os, Docx4J.FLAG_EXPORT_PREFER_XSL);
os.close();*/
baos = new ByteArrayOutputStream();
Docx4J.toFO(foSettings, baos, Docx4J.FLAG_EXPORT_PREFER_XSL);
byte[] pdf = baos.toByteArray();
updater = null;
foSettings = null;
wordMLPackage = null;
return pdf;
} catch (Docx4JException e) {
e.printStackTrace();
LOG.error(e.getMessage(), e);
}