Beispiel #1
0
 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();
     }
 }
Beispiel #2
0
        protected virtual void OnPreviewDrawingareaExposeEvent(object o, Gtk.ExposeEventArgs args)
        {
            DrawingArea area = (DrawingArea)o;

            if (designService.Report.Pages.Count > 0)
            {
                Cairo.Context cr = Gdk.CairoHelper.Create(area.GdkWindow);
                cr.Antialias           = Cairo.Antialias.None;
                reportRenderer.Context = cr;
                Cairo.Rectangle r = new Cairo.Rectangle(0, 0, designService.Report.WidthWithMargins, designService.Report.HeightWithMargins);
                cr.FillRectangle(r, backgroundPageColor);
                cr.Translate(designService.Report.Margin.Left, designService.Report.Margin.Top);
                reportRenderer.RenderPage(designService.Report.Pages [pageNumber]);
                area.SetSizeRequest((int)designService.Report.HeightWithMargins, (int)designService.Report.HeightWithMargins + 5);

                (cr as IDisposable).Dispose();
            }
        }