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

Free Support Forum - aspose.com

LINQ Reporting Engine throws System.ArgumentNullException when JsonDataSource has image using C#


I am generating document using LINQ Reporting which involves inserting images dynamically. I am using JsonDataSource as the datasource.

Getting exception “Buffer cannot be null. Parameter name: buffer”

Json Data

“Name”: “Ravi Kashyap”,
“Signature”: “”

If I use the concrete type then it works.

I have attached sample code/ project which has th template/ json file as embedded resource.

Can someone please suggest? I have to use jsondatareader as the data is dynamic.

Sample Code:

private static void GenerateDocumentFromJson_NotWorking()
byte[] generatedDocument;
// Get Template
var templateContent = ReadResourceData(“Sample_ImageTest01.docx”);

        // Get Json Data
        var templatDataContent = ReadResourceData("Sample_ImageTest01.json");

        // Load the template document.
        using (MemoryStream templateStream = new MemoryStream(templateContent))
            Document doc = new Document(templateStream);
            using (MemoryStream dataStream = new MemoryStream(templatDataContent))
                JsonDataSource jsonDataSource = new JsonDataSource(dataStream);

                // Create a Reporting Engine.
                ReportingEngine engine = new ReportingEngine();

                // Execute the build report.
                engine.BuildReport(doc, jsonDataSource, "data");

                // Save the finished document to disk.
                using (MemoryStream outStream = new MemoryStream())
                    doc.Save(outStream, SaveFormat.Docx);
                    generatedDocument = outStream.ToArray();
            File.WriteAllBytes($"Output_Sample_ImageTest01_{ DateTime.Now.ToString("dd_MM_yyyy_hh_mm_s")}.docx", generatedDocument);


RaviTestAsposeWordReporting.zip (53.9 KB)


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-19859. 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-19859) have been fixed in this Aspose.Words for .NET 20.2 update and this Aspose.Words for Java 20.2 update.