I'm trying to convert a docx file to pdf but it is not working. The document has text and images.
The command I'm using is:
- Code: Select all
java -cp docx4j-2.8.1.jar:log4j-1.2.15.jar:xmlgraphics-commons-1.4.jar:commons-logging-1.1.1.jar:xalan-2.7.1.jar:fop-1.0.jar:commons-io-1.3.1.jar:serializer-2.7.1.jar:avalon-framework-impl-4.3.1.jar:avalon-framework-api-4.3.1.jar org.docx4j.samples.ConvertOutPDF myfile.docx
and the error I get is:
- Code: Select all
Exception in thread "main" org.docx4j.openpackaging.exceptions.Docx4JException: FOP issues
at org.docx4j.convert.out.pdf.viaXSLFO.Conversion.output(Conversion.java:374)
at org.docx4j.samples.ConvertOutPDF.main(ConvertOutPDF.java:138)
Caused by: javax.xml.transform.TransformerException: org.apache.fop.fo.ValidationException: For "fo:root", "fo:layout-master-set" must be declared before "fo:page-sequence"! (See position 1:168)
at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:502)
at org.docx4j.convert.out.pdf.viaXSLFO.Conversion.output(Conversion.java:362)
... 1 more
Caused by: org.apache.fop.fo.ValidationException: For "fo:root", "fo:layout-master-set" must be declared before "fo:page-sequence"! (See position 1:168)
at org.apache.fop.events.ValidationExceptionFactory.createException(ValidationExceptionFactory.java:38)
at org.apache.fop.events.EventExceptionManager.throwException(EventExceptionManager.java:54)
at org.apache.fop.events.DefaultEventBroadcaster$1.invoke(DefaultEventBroadcaster.java:175)
at $Proxy36.nodeOutOfOrder(Unknown Source)
at org.apache.fop.fo.FONode.nodesOutOfOrderError(FONode.java:502)
at org.apache.fop.fo.FONode.nodesOutOfOrderError(FONode.java:488)
at org.apache.fop.fo.pagination.Root.validateChildNode(Root.java:128)
at org.apache.fop.fo.FOTreeBuilder$MainFOHandler.startElement(FOTreeBuilder.java:267)
at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:171)
at org.apache.xalan.transformer.TransformerIdentityImpl.startElement(TransformerIdentityImpl.java:1073)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:504)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:376)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2732)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:625)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:116)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:488)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:819)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:748)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1208)
at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:485)
... 2 more
Has anybody tried to save a pdf from a docxfile?
Thank you!