I’m trying to do a very basic image insertion, but when I try to open the result in Word 2013 I see “We’re sorry. We can’t open because we found a problem with its contents.”
If I choose to Recover the document, the file seems to be correct, but even if I re-save this recovered file, it still gives the same error message next time. This message should not be appearing at all! Why is it not being saved in a valid format?
I’ve upgraded to the latest version (17.9) but this problem remains.
I’m attaching the source code and the input document & image, and also including the source code below.
What can I do to resolve this? Thanks.
Code:
public static void AsposeSupportTestCase_WordDocIsCorrupted(byte[] wordDocFile, byte[] imageFile, string destinationFilename)
{
// SetLicense(); // License is being set here! This is happening on the full version, not a trial.
Aspose.Words.Document doc = new Aspose.Words.Document(new MemoryStream(wordDocFile));
Aspose.Words.DocumentBuilder builder = new Aspose.Words.DocumentBuilder(doc);
builder.InsertImage(imageFile);
byte[] resultBytes;
using (MemoryStream saveStream = new MemoryStream())
{
builder.Document.Save(saveStream, Aspose.Words.SaveFormat.Docx);
resultBytes = saveStream.ToArray();
}
System.IO.File.WriteAllBytes(destinationFilename, resultBytes);
}
asposeWordDocCorrupted.zip (12.1 KB)