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

Free Support Forum - aspose.com

Aspose.words save method throws null reference when using memorystream created from bytes

Hi,
When using Memorystream (created from bytes) to create a doc in aspose.words, the Save method is throwing null reference exception. Please let me know how this can be fixed.

         byte[] imgdata = null;
        string templateName = @"C:\Dev\SearchResultsTemplate.docx";
         imgdata = System.IO.File.ReadAllBytes(templateName);
         
         MemoryStream stream = new MemoryStream(imgdata);
        Aspose.Words.Document doc = new Aspose.Words.Document(stream);
         ReportingEngine engine = new ReportingEngine();            

engine.BuildReport(doc, datasources, datasourcenames);
doc.Save(“C:\Aspose\SearchOutput.pdf”); – this line throws null reference exception

@anupuga

Thanks for your inquiry. We have tested the scenario with a sample template and data, but we are unable to replicate the issue with memory stream. Please ZIP and attach the following resources to the post for testing. We will look into these and will guide you accordingly.

  • Share your input Word document
  • Attach the expected output Word document, you may create sample Word document using MS Word
  • Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end.