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

Free Support Forum - aspose.com

Aspose blocks the function if corrupted file is used


I am using Aspose for Word to PDF. The code I am using is -

Document document = new Document(sample.getAbsolutePath());
document.save(outputDocuments + FilenameUtils.removeExtension(sample.getName()) + docConversionExtension);

This blocks the process if a corrupted file is uploaded. This must ideally through an error.

Find attached sample file.
Input_Data.zip (5.3 KB)


Thanks for your inquiry. Please use FileFormatUtil.DetectFileFormat method to detect the information about a format of a document. The shared document is of type text. Please use following code example get the correct output.

LoadOptions options = new LoadOptions();
Document doc = new Document(MyDir + "test11.docx", options);
doc.save(MyDir + "17.9.pdf");

Moreover, please note that Aspose.Words requires TrueType fonts when rendering documents to fixed-page formats (JPEG, PNG, PDF or XPS). You need to install fonts that are used in your document on the machine where you’re converting documents to PDF. Please refer to the following article:

How Aspose.Words Uses True Type Fonts

Thanks for the response will check that.

For other file formats I don’t need to specify the loadFormat. Is this mentioned somewhere on developers guide.


Thanks for your inquiry. You do not need to use LoadOptions. Aspose.Words detects the text encoding of text file while importing it. However, for the shared document, you need to specify the text encoding. Please note that Aspose.Words mimics the same behaviour as MS Word does. If you open the document in MS Word, MS Word also does not detect its encoding. We suggest you please read following article.
Text Import Features

You text document have extension .docx. You can use Document.OriginalLoadFormat property to get the format of the original document that was loaded into this object.