System.ArgumentOutOfRangeException and System.ObjectDisposedException error

Hi,

I am thrown the following errors when trying to open a document using Aspose.

error1.doc
Type: System.ArgumentOutOfRangeException
Message: Non-negative number required.
Parameter name: count
StackTrace: at System.IO.BinaryReader.ReadBytes(Int32 count)

error2.doc
Type: System.ObjectDisposedException
Message: Cannot access a closed file.
StackTrace: at System.IO.__Error.FileNotOpen()

I am processing 100++ word documents. Majority of them are ok except with some documents that throw me the above errors. What might be the cause? I checked the content and couldnt identify any difference with other documents that are ok. Could it be those tables, picture?

I have attached the error documents. Please check.

Thanks a lot.

here is the error2.doc

here is the error1.doc

Error1.doc seems to have some invalid paragraph formatting info in the file, I’ve changed Aspose.Word code to be resillient and it processes the file okay. Note that in Erro1.doc you have two textboxes on top of each other and Aspose.Word loses their Z ordering. To avoid this problem remove one of the text boxes or move its anchor to another paragraph.

Error2.doc is not an MS Word .doc file. It is a .zip file containing .xml files - this is the “native” format of OpenOffice documents and Aspose.Word cannot open these files. I’ve made a fix however to throw a better error message.

The changes will be released in Aspose.Word 2.2.5 later today.

Hi,

I’ve downloaded Aspose.Word 2.2.5 and tested on my documents.
There are 3 types of error on my documents.
- Cannot recognize file format. (OpenOffice)
- The file is in RTF format and importing RTF files is not yet supported. (RTF)
- Sorry, but document format version is 6 and it is not currently supported. (Word95)

After i save these error files again in WordsXP format. It all works fine.

Do you guy plan to support OpenOffice,RTF or Word95 in the near future?
or is there a method i can know the type of document without opening the document using Microsoft Word or Open Office or Aspose? All these files are in .doc extension though the “real” format is different.
In my case, it is fine not to support open office, rtf and words95. but i need a method to know the “real” format of the document when they are uploading through our web page.

Thanks for all your prompt and efficient help! I can’t imagine u guy would able to release 2 versions within a day after customer post for some requests.

Thanks again,

Shu Yih

We plan to implement support of RTF format within 1-2 months. OpenOffice documents can be processed only if they were saved as “Word 97-2003” format. I don’t think we will add support for Word 95 files since Word 97 format is the base and compatible with all newer formats.

Regarding the method to obtain the “real” format of the document - for the time being the only way to perform it is catching the exception. But maybe we will add a method to validate input file format some time later.

Thanks. Looking forward for the new version.

Hi,

Aspose.Word 2.3 is released.

Added the Document.DetectFileFormat method to allow document format detection.

Thanks. Will Try it out.

Shu Yih

Hi,

I have tried out on my code. All of the documents are returned with correct file type except those document with Word 6 format. It is returned as FormatDocument type. Though it is come with correct error message “Sorry, but document format version is 6 and it is not currently supported.”, is it possible to return as someting like “FormatDoc6” ?

Thanks

Shu Yih

Hi,

Thank you for the suggestion. We cannot promise anything at the moment, but we will probably implement it later.

Thanks. Looking forward for the future version.

“We plan to implement support of RTF format within 1-2 months.”

Is rtf supported currently?

No, it isn’t supported yet. Unfortunately, our development plans can change due to shifting the priorities. So RTF support is still a few months away.