Aspose does not support empty docx file

When run

Document doc = new Document("empty.docx");

Got the following error: com.aspose.words.UnsupportedFileFormatException: Unknown file format.

Attached “empty.docx” has 0 size.

Thanks for help!

Hi Will,

Thanks for your inquiry. This is not a bug in Aspose.Words. In this case, the file with zero length has no header. All object files have the header by which one can understand that the format and version of the format.

You can check the file size before loading it into Aspose.Words.Document by using following code snippet.

File file = new File(MyDir + "empty.docx");
long size = file.length();
System.out.println("bytes : " + size);

Hope this answers your query. Please let us know if you have any more queries.