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

Free Support Forum - aspose.com

Word Document Template - Data Merge Rendering Issue

We are facing very critical issue, when we upgrading the Aspose.Words “19.10” to the latest version.

After we merge the data in word document template and save as pdf, the data-bound fields shows data without html rendering. Previously it is showing fine. Normal data without html tags working good.

Please see the attached program file to execute it and also attached sample template and merge data file. Review the final output document (before and after upgrade).

using (var docStream = new MemoryStream())
    // load word document template
    byte[] template = File.ReadAllBytes("MergeDataTemplate.docx");
    docStream.Write(template, 0, template.Length);

    using (var pkg = Package.Open(docStream, FileMode.Open, FileAccess.ReadWrite))
        using (var wordDoc = WordprocessingDocument.Open(pkg))
            // load merge data for word document
            string mergeDataXml = File.ReadAllText("MergeData.xml");
            var mergeDataDoc = new XmlDocument();

            // set merge data to word document template

            // merge data in word document template
            // save the word document template

    docStream.Seek(0, SeekOrigin.Begin);

    // save the word template to pdf
    using (var pdfStream = new MemoryStream())
        var saveOptions = (PdfSaveOptions)SaveOptions.CreateSaveOptions(SaveFormat.Pdf);
        saveOptions.FontEmbeddingMode = PdfFontEmbeddingMode.EmbedNonstandard;
        saveOptions.ImageCompression = PdfImageCompression.Jpeg;
        saveOptions.JpegQuality = 90;

        var document = new Document(docStream);
        document.Save(pdfStream, saveOptions);

        pdfStream.Seek(0, SeekOrigin.Begin);

        using (var fileStream = File.OpenWrite("FinalDocument.pdf"))
            pdfStream.Seek(0, SeekOrigin.Begin);

See attached file for the whole program.

FinalDocument_ACTUAL.pdf (39.4 KB)
FinalDocument_EXPECTED.pdf (67.8 KB)
MergeDataTemplate.docx (24.2 KB)
MergeData.xml.zip (1.1 KB)
Program.cs.zip (1.5 KB)


We tested the scenario and have managed to reproduce the same problem on our end. For the sake of any corrections in Aspose.Words API, we have logged this problem in our issue tracking system. The ID of this issue is WORDSNET-22507. We will further look into the details of this problem and will keep you updated on the status of linked issue. We apologize for your inconvenience.

I checked the program with different version of Aspose Words. This issue coming from version 20.10

There is no html rendering issue between 19.10 to 20.9 versions.


We have completed the analysis of WORDSNET-22507 and the root cause has been determined.

I have also logged these details in our issue tracking system and will keep you posted here on any further updates.