We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Parse DOCX File containing Mail Merge Fields using Aspose.Words for Java API

Hello, I’m using aspose-words-19.12-jdk16 and getting the error below when trying to parse a docx file :
Caused by: com.aspose.words.FileCorruptedException: The document appears to be corrupted and cannot be loaded.
at com.aspose.words.FileFormatUtil.Z(Unknown Source)
at com.aspose.words.Document.Z(Unknown Source)
at com.aspose.words.Document.Ã(Unknown Source)
at com.aspose.words.Document.(Unknown Source)
at com.aspose.words.Document.(Unknown Source)

Also, I tried to attach the file in question here but unable to.

@jkang777,

Please ZIP and upload your input DOCX Word document that you are unable to parse with Aspose.Words for Java API here for testing. We will then investigate the issue on our end and provide you more information.

DriverLicImage1X.docx.zip (10.2 KB)
Attached is the zipped docx file.
Thank you for looking into this issue!

@jkang777,

After an initial test with the licensed latest version of Aspose.Words for Java i.e. 19.12, we were unable to reproduce this com.aspose.words.FileCorruptedException error on our end. Please see the output PDF documents generated on our end by using the following simple code:

Java Code to Convert DOCX to PDF:

Document doc = new Document("E:\\DriverLicImage1X.docx\\DriverLicImage1X.docx");
doc.save("E:\\DriverLicImage1X.docx\\awjava-19.12.pdf");

So, please double check if you are referencing the correct latest Aspose.Words for Java’s JAR. In case the problem still remains, please also provide piece of source code that helps us to reproduce the same problem with DriverLicImage1X.docx on our end.

Thank you for the confirmation!
I was able to resolve the issue.
I had an old version of the Apose Word library in the same directory.

@jkang777,

It is great that you were able to resolve this issue on your end. Please let us know any time you have any further queries.