I’m trying to open a word document and I’m getting the exception below. Note that the attached document is blank document, I have removed all the data from the document. And I’m still getting exception. I’m using version 11.1.0.0
Aspose.Words.FileCorruptedException was unhandled by user code
HResult=-2146233088
Message=The document appears to be corrupted and cannot be loaded.
Source=Aspose.Words
StackTrace:
at Aspose.Words.Document.x5d4db34d48fb3129(Stream xcf18e5243f8d5fd3, LoadOptions x27aceb70372bde46)
at Aspose.Words.Document.x5d95f5f98c940295(Stream xcf18e5243f8d5fd3, LoadOptions x27aceb70372bde46)
at Aspose.Words.Document..ctor(Stream stream, LoadOptions loadOptions)
at Aspose.Words.Document..ctor(Stream stream)
at XXXXXX
InnerException: System.NullReferenceException
HResult=-2147467261
Message=Object reference not set to an instance of an object.
Source=Aspose.Words
StackTrace:
at xda075892eccab2ad.xc1b08afa36bf580c.xa9aaee2edd3cd025(String x971e83bc97861294, Byte[] xf9a0d04800d70471, Int32 x10aaa7cdfa38f254)
at x79490184cecf12a1.xc37fee571c29ba92.xdafccb198ba91439()
at x79490184cecf12a1.xc37fee571c29ba92.x2506b757d67702ec()
at x79490184cecf12a1.xc37fee571c29ba92.x902b6f807c71becd(x3dabda6865ed239d x8ad4cdceb54e447f)
at x79490184cecf12a1.xc37fee571c29ba92.xd4c5b858945b0ab2(x3dabda6865ed239d x8ad4cdceb54e447f)
at x79490184cecf12a1.xc37fee571c29ba92.x06b0e25aa6ad68a9(xa52ef41af20225f0 xe134235b3526fa75)
at x79490184cecf12a1.xa52ef41af20225f0.DoRead()
at x79490184cecf12a1.x11e1346c12ead315.x06b0e25aa6ad68a9()
at x79490184cecf12a1.xae13d15563a3a703.x748a2047fcb706ad()
at x79490184cecf12a1.xae13d15563a3a703.x06b0e25aa6ad68a9()
at Aspose.Words.Document.x5d4db34d48fb3129(Stream xcf18e5243f8d5fd3, LoadOptions x27aceb70372bde46)
InnerException:
Here is the code
public void Test()
{
using (var fs = new FileStream("Test.docx", FileMode.Open, FileAccess.Read))
{
using (var output = new FileStream("output.pdf", FileMode.Create, FileAccess.Write))
{
Aspose.Words.Document wordDocument = new Aspose.Words.Document(fs);
wordDocument.Save(output, Aspose.Words.SaveFormat.Pdf);
}
}
}