Aspose.Words throws NullReferenceException / FileCorruptedException when opening certain ODT files. I just tested using version 22.6 of Aspose.Words for .NET.
Here is the stack trace:
Aspose.Words.FileCorruptedException: The document appears to be corrupted and cannot be loaded.
---> System.NullReferenceException: Object reference not set to an instance of an object.
at hSa.a(KRa a, tRa b, CompositeNode c)
at hSa.a(KRa a, String b, CompositeNode c)
at vRa.e(KRa a, tRa b)
at vRa.d(KRa a, tRa b)
at vRa.a(KRa a)
at wRa.a(KRa a)
at VRa.a(KRa a)
at KRa.CcaOja()
at Aspose.Words.Document.b(Stream a, LoadOptions b)
--- End of inner exception stack trace ---
at Aspose.Words.Document.b(Stream a, LoadOptions b)
at Aspose.Words.Document.a(Stream a, LoadOptions b)
at Aspose.Words.Document..ctor(Stream stream, LoadOptions loadOptions)
at Aspose.Words.Document..ctor(Stream stream)
Here is the code creating the Aspose.Words.Document:
public Stream Convert2Pdf(Stream input, bool optimize)
{
optimize = true;
var doc = new Aspose.Words.Document(input);
var pdfStream = new MemoryStream();
doc.Save(pdfStream, GetSaveOptions(optimize));
return pdfStream;
}
I can send an example ODT file on request.