Hi there,
I’m trying to open a word document and convert to pdf file using something like below:
Document doc = new Document(sourcedocpath);
doc.save(destination + “/” + filename+ “.pdf”);
It works great for .doc files and some of the .docx files, but in some .docx files I got a FileCorruptedException in the first line. Error details as follows:
com.aspose.words.FileCorruptedException: The document appears to be corrupted and cannot be loaded.
at com.aspose.words.FileFormatUtil.a(Unknown Source)
at com.aspose.words.Document.b(Unknown Source)
at com.aspose.words.Document.a(Unknown Source)
at com.aspose.words.Document.(Unknown Source)
at com.aspose.words.Document.(Unknown Source)
Caused by: java.lang.NullPointerException
at com.aspose.words.afg.b(Unknown Source)
at com.aspose.words.ih.Ou(Unknown Source)
at com.aspose.words.ih.Ot(Unknown Source)
at com.aspose.words.ih.e(Unknown Source)
at com.aspose.words.ih.b(Unknown Source)
at com.aspose.words.ih.a(Unknown Source)
at com.aspose.words.gp.NA(Unknown Source)
at com.aspose.words.gq.read(Unknown Source)
at com.aspose.words.hp.NB(Unknown Source)
at com.aspose.words.hp.read(Unknown Source)
at com.aspose.words.Document.b(Unknown Source)
… 4 more
I have a couple of docx files that come from different sources that all encounter this issue, so I don’t think it’s something with a specific file itself. All these docx files open fine in MS Word so I’m not sure why some of these are working and some are not. I have attached one of the file that’s not working. I’m using the Aspose Words 15.8.0 version.
Any help would be appreciated.
Thanks! YZ