We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

System.NullReferenceException is thrown while saving first page of DOCX to JPEG using C#

test.zip (46.6 KB)

We are using Aspose.Words for .NET version 19.12, but I have also managed to reproduce the problem on 20.1

The code is as follows:

  var  doc = new Aspose.Words.Document(@"test.docx");
  int quality = 80;

  var imageSaveOptions = new Aspose.Words.Saving.ImageSaveOptions(Aspose.Words.SaveFormat.Jpeg);
  imageSaveOptions.JpegQuality = quality;
  imageSaveOptions.Resolution = 150;
  imageSaveOptions.PageCount = 1;

  var startPage = 0;

  for (int counter = startPage; counter < doc.PageCount; counter++)
    imageSaveOptions.PageIndex = counter;
    using (var imageStream = new MemoryStream())
      doc.Save(imageStream, imageSaveOptions);

the call to doc.Save(…) throws a NullReferenceException on the first page of the file.
Please find the problematic file test.docx attached in the ZIP.

Please let us know when this can be fixed.


We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-19783 . You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

The issues you have found earlier (filed as WORDSNET-19783) have been fixed in this Aspose.Words for .NET 20.2 update and this Aspose.Words for Java 20.2 update.