Open yonglih opened 8 years ago
It's a problem with classpath. If you use maven, it should work. Check you hav ethe well POI Jar
I will test,thank you!
org.apache.poi.POIXMLException: org.apache.poi.openxml4j.exceptions.InvalidFormatException: Package should contain a content type part [M1.13]
How to resolve this problem?
@yonglih your problem is about POI and not about XDocReport. So please post your question to the POI forum. Your error seems that your docx is not a valid docx.
Sorry.Actually,I have tried to use XDocReport to convert docx to PDF,but failed.So,there will be some problems about XDocReport to show you below: I just copy the instance of code to run ,but throw a exception below, java.io.IOException: InputStream is not a zip. these are related codes: InputStream in = DocToPdf.class .getResourceAsStream("DocxProjectWithVelocity_Out.docx"); IXDocReport report = XDocReportRegistry.getRegistry().loadReport( in, TemplateEngineKind.Velocity);
@yonglih I have not a lot of time. If you need help, please share your project. It seems taht DocxProjectWithVelocity_Out.docx is not a valid docx.
OK,I will check,thank you.
I use IntelliJ to product, test by these steps below: // 1) Load DOCX into XWPFDocument InputStream in= new FileInputStream(new File("HelloWord.docx")); XWPFDocument document = new XWPFDocument(in);
// 2) Prepare Pdf options PdfOptions options = PdfOptions.create();
// 3) Convert XWPFDocument to Pdf OutputStream out = new FileOutputStream(new File("HelloWord.pdf")); PdfConverter.getInstance().convert(document, out, options);
then,it can product a PDF file,but throw exceptions below: java.lang.NoClassDefFoundError: Could not initialize class org.apache.poi.xwpf.usermodel.XWPFDocument. and the PDF file can not be opened.
could you give me some suggestions to resolve the problem?