LINQ Reporting Engine does not Insert Image into Document from JSON Data Source using .NET

Hi,

We have requirement to print Images in table row by side by side. We followed one syntax (mentioned in SampleReport.docx) to print images side by side. If we have multiple images able to see the Image in document where as if we have single image we could see blank space.

Please let us know your suggestion.

Attached SampleJosn.docx and SampleReport.docx for reference.

Thanks.

SampleJson.docx (12.7 KB)

SampleReport.docx (19.4 KB)

@nageshcrm

Unfortunately, the shared JSON is not readable by APIs. Please attach the following resources here for testing:

  • Your JSON data source (text file format).
  • Please attach the output Word file that shows the undesired behavior.
  • Please attach the expected output Word file that shows the desired behavior.
  • Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.

Hi Tahir,

Thanks for your quick response.

Attached the requested Inputs for refence.

Inputs.zip (99.1 KB)

@nageshcrm

Please share the requested resources here for testing. Thanks for your cooperation.

Hi Tahir,

We are integrating ASPOSE with Dynamics 365 CRM and we are unable to share our code. Please let us know any alterative solution is there.

Attached expected output document and Json for reference.

Thanks.

Inputs.zip (100.8 KB)

@nageshcrm

We have changed the images link in JSON with base64 images and use following code example to reproduce the issue. The modified JSON is attached. SampleJson.zip (14.0 KB)

We have logged this problem in our issue tracking system as WORDSNET-22770. You will be notified via this forum thread once this issue is resolved. We apologize for your inconvenience.

var doc = new Aspose.Words.Document(MyDir + "SampleReport.docx");
var json = File.ReadAllText(MyDir + "SampleJson.txt");

JsonDataLoadOptions options = new JsonDataLoadOptions();
options.SimpleValueParseMode = JsonSimpleValueParseMode.Strict;

var dataStream = new MemoryStream(Encoding.ASCII.GetBytes(json));
var jsonDataSource = new JsonDataSource(dataStream, options);

var engine = new ReportingEngine();
engine.Options = ReportBuildOptions.AllowMissingMembers;
engine.BuildReport(doc, jsonDataSource);

doc.Save(MyDir + "21.9.docx");

We have tested the scenario and 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-22770. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

@nageshcrm

It is to inform you that your issue WORDSNET-22770 has been closed as ‘Not a bug’.

In your template document, the shape that is visually the second in the report template is actually located before the visually-first shape. Please set the shapes’ wrap type as inline to see the actual template syntax.

You can set the shape wrap type as inline and put the <<next>> tag in first shape to avoid the shared issue. Please check the modified input and output documents in attachment. 21.9.docx (27.1 KB)
SampleReport.docx (20.2 KB)

@tahir.manzoor

Thanks Its working now. But In Json we have date format like “26/Aug/2021”, in document we could see different format like 8/26/2021 12:00:00 AM.

Please let us know your suggestion.

Thanks.

@nageshcrm

Please use JsonDataLoadOptions.ExactDateTimeParseFormats property to get or set exact formats for parsing JSON date-time values while loading JSON. You can achieve this by specifying one or several exact formats in the context of the current culture to be used while parsing date-time values from strings as shown in the following example.

var doc = new Aspose.Words.Document(MyDir + "SampleReport.docx");
var json = File.ReadAllText(MyDir + "SampleJson.txt");

List<String> formats = new List<String>();
formats.Add("yyyy-MM-dd");

JsonDataLoadOptions options = new JsonDataLoadOptions();
options.SimpleValueParseMode = JsonSimpleValueParseMode.Strict;
options.ExactDateTimeParseFormats = formats;

var dataStream = new MemoryStream(Encoding.ASCII.GetBytes(json));
var jsonDataSource = new JsonDataSource(dataStream, options);

var engine = new ReportingEngine();
engine.Options = ReportBuildOptions.AllowMissingMembers;
engine.BuildReport(doc, jsonDataSource);

doc.Save(MyDir + "21.9.docx");

@tahir.manzoor

Date format working fine.

Thanks.