diff --git a/RdlGtkViewer/RdlGtkViewer/ReportViewer.cs b/RdlGtkViewer/RdlGtkViewer/ReportViewer.cs index 8b734f85..b5093ab6 100644 --- a/RdlGtkViewer/RdlGtkViewer/ReportViewer.cs +++ b/RdlGtkViewer/RdlGtkViewer/ReportViewer.cs @@ -44,6 +44,7 @@ public partial class ReportViewer : Gtk.Bin private string connectionString; private bool overwriteSubreportConnection; private OutputPresentationType[] restrictedOutputPresentationTypes; + private Action customPrintAction; public event EventHandler ReportPrinted; @@ -112,12 +113,14 @@ public ReportViewer() /// Relace all Connection string in report. /// If true connection string in subreport also will be overwrite /// Restricts to chose from in export dialog - public void LoadReport (Uri filename, string parameters, string connectionString, bool overwriteSubreportConnection = false, OutputPresentationType[] restrictedOutputPresentationTypes = null) + /// >For use a custom print action + public void LoadReport (Uri filename, string parameters, string connectionString, bool overwriteSubreportConnection = false, OutputPresentationType[] restrictedOutputPresentationTypes = null, Action customPrintAction = null) { SourceFile = filename; this.connectionString = connectionString; this.overwriteSubreportConnection = overwriteSubreportConnection; + this.customPrintAction = customPrintAction; LoadReport (filename, parameters, restrictedOutputPresentationTypes); } @@ -637,18 +640,25 @@ protected void OnPrintActionActivated(object sender, System.EventArgs e) { using (PrintContext context = new PrintContext(GdkWindow.Handle)) { - printing = new PrintOperation(); - printing.Unit = Unit.Points; - printing.UseFullPage = true; - printing.DefaultPageSetup = new PageSetup(); - printing.DefaultPageSetup.Orientation = - report.PageHeightPoints > report.PageWidthPoints ? PageOrientation.Portrait : PageOrientation.Landscape; - - printing.BeginPrint += HandlePrintBeginPrint; - printing.DrawPage += HandlePrintDrawPage; - printing.EndPrint += HandlePrintEndPrint; - - printing.Run(PrintOperationAction.PrintDialog, null); + if (customPrintAction == null) + { + printing = new PrintOperation(); + printing.Unit = Unit.Points; + printing.UseFullPage = true; + printing.DefaultPageSetup = new PageSetup(); + printing.DefaultPageSetup.Orientation = + report.PageHeightPoints > report.PageWidthPoints ? PageOrientation.Portrait : PageOrientation.Landscape; + + printing.BeginPrint += HandlePrintBeginPrint; + printing.DrawPage += HandlePrintDrawPage; + printing.EndPrint += HandlePrintEndPrint; + + printing.Run(PrintOperationAction.PrintDialog, null); + } + else + { + customPrintAction.Invoke(pages); + } } }