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);
}