Problems with Accent Characters Aspose.Words

Hi,
I am having the same issue. What was the outcome for this please?

@pboothappliedsystems Could you please attach your problematic input and output documents here for testing? We will check the issue and provide you more information.

Accented Test.docx (83.5 KB)
Renewal Invitation.docx (84.9 KB)
Hi,
I have attached the input document “Renewal Invitation.docx” and output document “Accented Test.docx” as requested. I am using a JsonDataSource with ReportEngine to BuildReport. In the attached documents the <<[Policy.FirstName]>> has a value of “Pául” in the JSON datasource and the <<[Policy.LastName]>> has a value of “Tést” in the data source. As you can see from the output document both of the accented characters have rendered as “?”.
For reference, I have an Aspose Total.net license.
Thanks for your help.

@pboothappliedsystems Could you please provide also you sample data source and specify which version of Aspose.Words you use (Java, .NET, C++ or Python)? Also, please describe your environment. We will check the scenario on our side and provide you more information.

DataSourceSample.zip (563 Bytes)
The attached .zip has a sample datasource JSON file (I had to add it to a zip as your upload doesn’t allow .json files)
The version of Aspose.Words I am using is .net.
The environment is a Windows 2019 server. I am using Visual Studio 2022 as an IDE.
Thanks.

@pboothappliedsystems Thank you for additional information. Unfortunately, I cannot reproduce the problem on my side using the latest 23.7 version of Aspose.Words. Here is code I have used for testing:

Document doc = new Document(@"C:\Temp\Renewal Invitation.docx");

JsonDataSource ds = new JsonDataSource(@"C:\Temp\DataSourceSample.json");
ReportingEngine engine = new ReportingEngine();
engine.BuildReport(doc, ds);

doc.Save(@"C:\Temp\out.docx");

here is the output: out.docx (73.8 KB)

Hi,
My code is a method I call that takes in the JSON data as a string that I have received from an API. So it isn’t actually in a JSON file. I put it in a file to send to you as an example. Because I am passing the JSON as a string I am creating the JsonDataSource from a Stream as per my code below.

public static void CreateReportDocument(string templateFile, string jsonData, string outputFile)
    {
        AsposeWordsLicense.SetLicense("Aspose.Total.NET.lic");

        CultureInfo.CurrentCulture = new CultureInfo("en-GB", false);

        Document templateDocument = new(templateFile);

        byte[] data = Encoding.ASCII.GetBytes(jsonData);
        var stream = new MemoryStream(data);
        JsonDataSource dataSource = new(stream);
        ReportingEngine engine = new();
        engine.Options |= ReportBuildOptions.AllowMissingMembers;
        engine.Options |= ReportBuildOptions.InlineErrorMessages;

        engine.BuildReport(templateDocument, dataSource);

        templateDocument.Save(outputFile);
    }

@pboothappliedsystems The problem occurs upon decoding string to byte array. Please try using UTF8 encoding:

byte[] data = Encoding.UTF8.GetBytes(jsonData);
var stream = new MemoryStream(data);
1 Like

Perfect. That was the issue. Really appreciate your help, especially as the actually cause was not related to Aspose.

1 Like