public static void ExportToPdf(this Report report ,string path)
{
using (PdfSurface pdfSurface = new PdfSurface (
path,report.WidthWithMargins,report.HeightWithMargins)) {
Cairo.Context cr = new Cairo.Context (pdfSurface);
cr.Translate(report.Margin.Left,report.Margin.Top);
ReportRenderer renderer = new ReportRenderer (){ Context = cr};
renderer.RegisterRenderer (typeof(TextBlock), new TextBlockRenderer ());
renderer.RegisterRenderer (typeof(Line), new LineRenderer ());
renderer.RegisterRenderer (typeof(Image), new ImageRenderer (){ PixbufRepository = new PixbufRepository(report.ResourceRepository)});
SectionRenderer sr = new SectionRenderer();
renderer.RegisterRenderer(typeof(ReportHeaderSection), sr);
renderer.RegisterRenderer(typeof(ReportFooterSection), sr);
renderer.RegisterRenderer(typeof(DetailSection), sr);
renderer.RegisterRenderer(typeof(PageHeaderSection), sr);
renderer.RegisterRenderer(typeof(PageFooterSection), sr);
MonoReports.Model.Engine.ReportEngine engine = new MonoReports.Model.Engine.ReportEngine (report,renderer);
engine.Process ();
for (int i = 0; i < report.Pages.Count; ++i) {
renderer.RenderPage (report.Pages [i]);
cr.ShowPage ();
}
pdfSurface.Finish ();
(cr as IDisposable).Dispose ();
}
}