I use telerik reporting to generate PDF reports in an ASP.NET MVC app, then i combine them into a single one using iText Sharp.
Each report has a page number, that i set using the PageNumber
binding on the designer:
The PageNumber
is starting from 1 for each report, so when i combine them i have something like; [1, 2, 3], [1, 2] ...
How do i tell the report to start the page number from a specific number so that i will have a consistent report [1, 2, 3, 4, 5 ..]?
public class ReportGenerator : IReportGenerator
{
private byte[] GenerateReport<TReport, TData>(TData data) where TReport : Report, new()
{
Report reportDefinition = new TReport();
reportDefinition.DataSource = data;
ReportProcessor processor = new ReportProcessor();
RenderingResult result = processor.RenderReport("PDF", new InstanceReportSource() {ReportDocument = reportDefinition},
new Hashtable());
if (result.HasErrors)
{
throw new AggregateException("There were errors in the reportGeneration");
}
return result.DocumentBytes;
}
public byte[] GenerateMyReport(TheReportViewModel reportVM)
{
return GenerateReport<TheReportDefinedUsingTheDesigner,TheReportViewModel>(reportVM);
}
}
I generate multiple reports using GenerateMyReport
then i combine them using iText Sharp.
Any help would be appreciated.
I figure it out.
The page binding has to be set to =Cint(PageNumber) + Cint(Fields.StartPageNumber)
Where PageNumber
is a predefined telerik report field, and StartPageNumber
is a property that you add to you report's ViewModel