Does docx4j only support converting docx to pdf?
Thanks
Here is my code
- Code: Select all
....
string fileIN = projectDir + @"src\samples\resources\sample-xlsx.xlsx";
string fileOUT = projectDir + @"OUT_sample-xlsx.pdf";
....
SpreadsheetMLPackage excelMLPackage = SpreadsheetMLPackage
.load(new java.io.File(fileIN));
org.docx4j.events.StartEvent startEvent = new org.docx4j.events.StartEvent(excelMLPackage, org.docx4j.events.WellKnownProcessSteps.PDF);
startEvent.publish();
org.docx4j.convert.@out.FOSettings settings = new org.docx4j.convert.@out.FOSettings();
settings.setWmlPackage(excelMLPackage);
settings.setApacheFopMime("application/pdf");
org.docx4j.convert.@out.common.Exporter exporter = org.docx4j.convert.@out.fo.FOExporterXslt.getInstance();
exporter.export(
settings
, new java.io.FileOutputStream(new java.io.File(fileOUT))
);
....
Error details:
[ERROR] org.docx4j.convert.out.common.AbstractExporter - Exception exporting pac
kage
org.docx4j.openpackaging.exceptions.Docx4JException: Invalid document package in
the settings, it isn't a WordprocessingMLPackage
Unhandled Exception: org.docx4j.openpackaging.exceptions.Docx4JException: Except
ion exporting package ---> org.docx4j.openpackaging.exceptions.Docx4JException:
Invalid document package in the settings, it isn't a WordprocessingMLPackage
at org.docx4j.convert.out.common.AbstractWmlExporter.preprocess(AbstractConve
rsionSettings conversionSettings)
at org.docx4j.convert.out.common.AbstractWmlExporter.<bridge>preprocess(Abstr
actConversionSettings x0)
at org.docx4j.convert.out.common.AbstractExporter.export(AbstractConversionSe
ttings conversionSettings, OutputStream outputStream)
--- End of inner exception stack trace ---
at org.docx4j.convert.out.common.AbstractExporter.export(AbstractConversionSe
ttings conversionSettings, OutputStream outputStream)
at docx4j.NET.samples.XlsxToPDF.Main(String[] args)