AppendDocument not working

I am evaluating the product and using some simple code to append multiple templates to one output file. However only the first page is saved. If i create an empty document and then use AppendDocument, nothing is saved except a blank page. What is the correct way to use AppendDocument when i have multiple templates i need to save to a single output file?

 public static void StampTemplates(string inputJson, List<string> templateLocation, string mergedLocation)
    {
        List<Document> documents = new List<Document>();
        ReportingEngine engine = new ReportingEngine {Options = ReportBuildOptions.AllowMissingMembers | ReportBuildOptions.RemoveEmptyParagraphs};
        foreach (var template in templateLocation)
        {
            Document doc = new Document(new MemoryStream(File.ReadAllBytes(template)));
            JsonDataLoadOptions options = new JsonDataLoadOptions
            {
                AlwaysGenerateRootObject = true,
                SimpleValueParseMode = JsonSimpleValueParseMode.Strict
            };
            var ds = new JsonDataSource(new MemoryStream(Encoding.UTF8.GetBytes(inputJson)), options);
            engine.BuildReport(doc, ds, "policy");
            documents.Add(doc);
            if(templateLocation.IndexOf(template) != 0)
                    documents[0].AppendDocument(doc,ImportFormatMode.KeepSourceFormatting);
        }
        documents[0].Save(mergedLocation);
    }

@exuviae

In case you are using old version of Aspose.Words, we suggest you please upgrade to the latest version of Aspose.Words for .NET 21.9 and let us know how it goes on your side.

If you still face problem, please attach the following resources here for testing:

  • Your input Word document.
  • 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.