Merging PDFs using the jsreport client
-
Hi,
I'm using the jsreport.client nuget package for .Net and happily producing single PDFs. I want to merge multiple PDFs into a single file, how do I achieve this in code, is there a sample I can reference.
Cheers
-
Try something like this, we will add it to the docs.
rs.RenderAsync(new RenderRequest { Template = new Template() { Content = "Helo world", Engine = Engine.Handlebars, Recipe = Recipe.ChromePdf, Chrome = new Chrome { MarginTop = "2cm" }, PdfOperations = new List<PdfOperation>() { new PdfOperation() { Type = PdfOperationType.Merge, Template = new Template { Content = "header", Engine = Engine.None, Recipe = Recipe.ChromePdf } } } } });
-
Thank you for the example, the example is for a newly created template right. I should have made it clear that I already have a report built in the designer and want to append the same report with different details multiple times. I'm wondering if there is a better way that doesn't require a merge. For example in the invoice example in the playground site is it possible to send 2 (or more) records through in the JSON file which results in multiple pages being produced for different companies, does that make sense? Note also that in my case a single report contains multiple pages.
-
Ok. So lets say you want to generate multiple invoices in single report.
You just need to pass an array in the json and iterate over it through templating engine.{{#each items}} <h1>Invoice {{id}}</h1> .... {{/each}}
-
Cool, I'll give that a go, thanks.