Free Support Forum -

IllegalStateException: Unknown file format

Receive the following error:

Error occured while opening the document
java.lang.IllegalStateException: Unknown file format.
at com.aspose.words.Document.a(Unknown Source)
at com.aspose.words.Document.(Unknown Source)
at com.aspose.words.Document.(Unknown Source)
at com.aspose.words.Document.(Unknown Source)


com.aspose.words.Document doc = new com.aspose.words.Document(service.readDoc(fileId));

Where "service.readDoc" is

public InputStream readDoc(String strDocSeqNo) throws Exception {
// query to retrieve the document.
String GETDOC = "select docBdy from Docs where docSeqNo=:searchString";
// executethe query.
List l = HibernateUtil.retrieveObjs(GETDOC, strDocSeqNo.trim());

// return the document as an inputstream.
return ((Blob) l.get(0)).getBinaryStream();
}// end of method - readDoc().

Have also tried the code below without success:

com.aspose.words.Document doc = new com.aspose.words.Document(service.readDoc(fileId), "", LoadFormat.FORMAT_DOCUMENT, "");

Also, when using this parameter, LoadFormat.FormatDocument, I get "LoadFormat cannot be resolved" error.

Please attach the document that causes the error. I will check what could be done.

Document attached:

I found the problem. The document had a file extension of .doc but was actually an RTF document. When I ran Aspose in a test program it did give an error message about this.

Thanks anyway.