public static void PrintAll(IEnumerable<IPrintableDocument> documents) { if(Environment.OSVersion.Platform != PlatformID.MacOSX && Environment.OSVersion.Platform != PlatformID.Unix) { PrintAll_Win_Workaround(documents); return; } PrintOperation printOp; printOp = new PrintOperation(); printOp.Unit = Unit.Points; printOp.UseFullPage = true; printOp.ShowProgress = true; var documentsRDL = documents.Where(doc=>doc.PrintType==PrinterType.RDL).ToList(); BatchRDLRenderer renderer = new BatchRDLRenderer(documentsRDL); var result = LongOperationDlg.StartOperation( renderer.PrepareDocuments, "Подготовка к печати...", documentsRDL.Count() ); if (result == LongOperationResult.Canceled) return; printOp.NPages = renderer.PageCount; if (documentsRDL.Any(x => x.Orientation == DocumentOrientation.Landscape)) { printOp.RequestPageSetup += renderer.RequestPageSetup; } printOp.DrawPage += renderer.DrawPage; printOp.Run(PrintOperationAction.PrintDialog, null); }
public CachePrinter() { m_print = new PrintOperation(); m_print.BeginPrint += HandleM_printBeginPrint; m_print.DrawPage += HandleM_printDrawPage; m_print.EndPrint += HandleM_printEndPrint; }
public DemoPrinting () { print = new PrintOperation (); print.BeginPrint += new BeginPrintHandler (OnBeginPrint); print.DrawPage += new DrawPageHandler (OnDrawPage); print.EndPrint += new EndPrintHandler (OnEndPrint); print.Run (PrintOperationAction.PrintDialog, null); }
private void PrintDoc(SelectablePrintDocument doc, PageOrientation orientation, int copies) { if (doc == null) { return; } switch (doc.Document.PrintType) { case PrinterType.RDL: var reportInfo = (doc.Document as IPrintableRDLDocument).GetReportInfo(); var action = showDialog ? PrintOperationAction.PrintDialog : PrintOperationAction.Print; showDialog = false; Printer = new PrintOperation(); Printer.Unit = Unit.Points; Printer.UseFullPage = true; Printer.PrintSettings = PrintSettings ?? new PrintSettings(); Printer.PrintSettings.Orientation = orientation; var rprint = new ReportPrinter(reportInfo); rprint.PrepareReport(); Printer.NPages = rprint.PageCount; Printer.PrintSettings.NCopies = copies; if (copies > 1) { Printer.PrintSettings.Collate = true; } Printer.DrawPage += rprint.DrawPage; Printer.Run(action, null); PrintSettings = Printer.PrintSettings; break; case PrinterType.ODT: case PrinterType.None: default: break; } }
void HandleActivated (object sender, EventArgs e) { // Commit any pending changes. PintaCore.Tools.Commit (); var op = new PrintOperation (); op.BeginPrint += HandleBeginPrint; op.DrawPage += HandleDrawPage; var result = op.Run (PrintOperationAction.PrintDialog, PintaCore.Chrome.MainWindow); if (result == PrintOperationResult.Apply) { // TODO - save print settings. } else if (result == PrintOperationResult.Error) { // TODO - show a proper dialog. System.Console.WriteLine ("Printing error"); } }
public Page() { // All this is only a test. Console.WriteLine("uno"); this.printOperation = new PrintOperation(); printOperation.NPages = 1; printOperation.Unit = Unit.Mm; printOperation.JobName = "PruebaConCairo"; // PrintSettings settings = new PrintSettings(); // settings.UseColor = true; // printOperation.PrintSettings = settings; Console.WriteLine("dos"); // printOperation.BeginPrint += this.BeginPrint; printOperation.DrawPage += this.DrawPage; printOperation.EndPrint += this.EndPrint; }
public static void Main(string[] Pages) { Application.Init(); var print = new Gtk.PrintOperation(); print.PrintSettings = new Gtk.PrintSettings(); print.PrintSettings.Scale = 33.75; print.PrintSettings.Resolution = 1200; print.JobName = "FeuerwehrCloud Ausdruck"; print.BeginPrint += (obj2, args) => { print.NPages = Pages.Length; }; print.DrawPage += (obj2, args) => { try { FeuerwehrCloud.Helper.Logger.WriteLine("| > [ImagePrinter] *** Page " + args.PageNr.ToString() + " of " + Pages.Length.ToString()); var imageBit = default(byte[]); var image = System.Drawing.Image.FromFile("/tmp/" + Pages[args.PageNr]); using (var memoryStream = new MemoryStream()) { image.Save(memoryStream, System.Drawing.Imaging.ImageFormat.Png); imageBit = memoryStream.ToArray(); } Gtk.PrintContext context = args.Context; try { var pixBuf = new Gdk.Pixbuf(imageBit, image.Width, image.Height); try { Cairo.Context cr = context.CairoContext; cr.MoveTo(0, 0); Gdk.CairoHelper.SetSourcePixbuf(cr, pixBuf, 0, 10); cr.Paint(); ((IDisposable)cr).Dispose(); } catch (Exception ex4) { FeuerwehrCloud.Helper.Logger.WriteLine("||| > [ImagePrinter] *** ERROR: " + ex4.ToString()); } } catch (Exception ex5) { FeuerwehrCloud.Helper.Logger.WriteLine("||| > [ImagePrinter] *** ERROR: " + ex5.ToString()); } } catch (Exception ex3) { FeuerwehrCloud.Helper.Logger.WriteLine("||| > [ImagePrinter] *** ERROR: " + ex3.ToString()); } }; print.EndPrint += (obj2, args) => { FeuerwehrCloud.Helper.Logger.WriteLine("| > [ImagePrinter] *** Printing finished "); Application.Quit(); }; print.Run(Gtk.PrintOperationAction.Print, null); }
private void PrintDoc(RouteList route, RouteListPrintableDocuments type, PageOrientation orientation, int copies) { var reportInfo = PrintRouteListHelper.GetRDL(route, type, uow); var action = showDialog ? PrintOperationAction.PrintDialog : PrintOperationAction.Print; showDialog = false; Printer = new PrintOperation(); Printer.Unit = Unit.Points; Printer.UseFullPage = true; //Printer.DefaultPageSetup = new PageSetup(); if (PrintSettings == null) { Printer.PrintSettings = new PrintSettings(); } else { Printer.PrintSettings = PrintSettings; } Printer.PrintSettings.Orientation = orientation; var rprint = new ReportPrinter(reportInfo); rprint.PrepareReport(); Printer.NPages = rprint.PageCount; Printer.PrintSettings.NCopies = copies; if (copies > 1) { Printer.PrintSettings.Collate = true; } Printer.DrawPage += rprint.DrawPage; Printer.Run(action, null); PrintSettings = Printer.PrintSettings; }
public Report(string reportName, string svgFile) { // Load svg file this.svgDocument = new SvgDocument(svgFile); // Create PrintOperation object this.printOperation = new PrintOperation(); this.printOperation.NPages = 1; this.printOperation.Unit = Unit.Mm; this.printOperation.JobName = reportName; this.printOperation.ExportFilename = "test.pdf"; PrintSettings psettings = new PrintSettings(); PaperSize paperSize = new PaperSize("customPaperSize", "cps", this.svgDocument.PageWidth, this.svgDocument.PageHeight, Unit.Mm); psettings.PaperSize = paperSize; Console.WriteLine("PageHeight: " + this.svgDocument.PageHeight.ToString()); Console.WriteLine("PageWidth: " + this.svgDocument.PageWidth.ToString()); Console.WriteLine(); this.printOperation.PrintSettings = psettings; printOperation.DrawPage += this.DrawPage; printOperation.BeginPrint += this.BeginPrint; // Set default action this.action = PrintOperationAction.Export; // Data this.data = new Dictionary<string, string>(); this.dataTables = new Dictionary<string, DataTable>(); this.pageHeader = this.svgDocument.PageHeaderSection; this.pageDetail = this.svgDocument.PageDetailSection; this.pageFooter = this.svgDocument.PageFooterSection; }
protected virtual void OnPrintActionActivated(object sender, System.EventArgs e) { using (PrintContext context = new PrintContext(GdkWindow.Handle)) { printing = new PrintOperation(); printing.Unit = Unit.Points; printing.UseFullPage = false; printing.BeginPrint += HandlePrintBeginPrint; printing.DrawPage += HandlePrintDrawPage; printing.EndPrint += HandlePrintEndPrint; printing.Run(PrintOperationAction.PrintDialog, null); } }
void miPrint_ButtonPressEvent(object o, ButtonPressEventArgs args) { PrintOperation po = new PrintOperation(); po.BeginPrint += delegate(object o2, BeginPrintArgs args2) { po.NPages = 1; }; po.DrawPage += delegate(object o2, DrawPageArgs args2) { GTKGraphics dg = new GTKGraphics(CairoHelper.GetContext(args2.Context)); DPrintViewer dvPrint = new DPrintViewer(); dvPrint.SetPageSize(de.PageSize); GTKPrintSettings dps = new GTKPrintSettings(args2.Context.DpiX, args2.Context.DpiY, args2.Context.PageSetup); dvPrint.Paint(dg, dps, de.BackgroundFigure, de.Figures); }; po.Run(PrintOperationAction.PrintDialog, this); }
public CustomPrintWidget(PrintOperation print_operation) : base(2, 4, false) { this.print_operation = print_operation; preview_image = new Gtk.Image (); Attach (preview_image, 0, 2, 0, 1); Frame page_frame = new Frame (Catalog.GetString ("Page Setup")); VBox page_box = new VBox (); Label current_settings = new Label (); if (FSpot.Core.Global.PageSetup != null) current_settings.Text = String.Format (Catalog.GetString ("Paper Size: {0} x {1} mm"), Math.Round (print_operation.DefaultPageSetup.GetPaperWidth (Unit.Mm), 1), Math.Round (print_operation.DefaultPageSetup.GetPaperHeight (Unit.Mm), 1)); else current_settings.Text = String.Format (Catalog.GetString ("Paper Size: {0} x {1} mm"), "...", "..."); page_box.PackStart (current_settings, false, false, 0); Button page_setup_btn = new Button (Catalog.GetString ("Set Page Size and Orientation")); page_setup_btn.Clicked += delegate { this.print_operation.DefaultPageSetup = Print.RunPageSetupDialog (null, print_operation.DefaultPageSetup, this.print_operation.PrintSettings); current_settings.Text = String.Format (Catalog.GetString ("Paper Size: {0} x {1} mm"), Math.Round (print_operation.DefaultPageSetup.GetPaperWidth (Unit.Mm), 1), Math.Round (print_operation.DefaultPageSetup.GetPaperHeight (Unit.Mm), 1)); }; page_box.PackStart (page_setup_btn, false, false, 0); page_frame.Add (page_box); Attach (page_frame, 1, 2, 3, 4); Frame ppp_frame = new Frame (Catalog.GetString ("Photos per page")); Table ppp_tbl = new Table(2, 7, false); ppp_tbl.Attach (ppp1 = new RadioButton ("1"), 0, 1, 1, 2); ppp_tbl.Attach (ppp2 = new RadioButton (ppp1, "2"), 0, 1, 2, 3); ppp_tbl.Attach (ppp4 = new RadioButton (ppp1, "2 x 2"), 0, 1, 3, 4); ppp_tbl.Attach (ppp9 = new RadioButton (ppp1, "3 x 3"), 0, 1, 4, 5); ppp_tbl.Attach (ppp20 = new RadioButton (ppp1, "4 x 5"), 0, 1, 5, 6); ppp_tbl.Attach (ppp30 = new RadioButton (ppp1, "5 x 6"), 0, 1, 6, 7); ppp_tbl.Attach (repeat = new CheckButton (Catalog.GetString ("Repeat")), 1, 2, 2, 3); ppp_tbl.Attach (crop_marks = new CheckButton (Catalog.GetString ("Print cut marks")), 1, 2, 3, 4); // crop_marks.Toggled += TriggerChanged; ppp_frame.Child = ppp_tbl; Attach (ppp_frame, 0, 1, 1, 2); Frame layout_frame = new Frame (Catalog.GetString ("Photos layout")); VBox layout_vbox = new VBox(); layout_vbox.PackStart (fullpage = new CheckButton (Catalog.GetString ("Full Page (no margin)")), false, false, 0); HBox hb = new HBox (); // Note for translators: "Zoom" is a Fit Mode hb.PackStart (zoom = new RadioButton (Catalog.GetString ("Zoom")), false, false, 0); hb.PackStart (fill = new RadioButton (zoom, Catalog.GetString ("Fill")), false, false, 0); hb.PackStart (scaled = new RadioButton (zoom, Catalog.GetString ("Scaled")), false, false, 0); zoom.Toggled += TriggerChanged; fill.Toggled += TriggerChanged; scaled.Toggled += TriggerChanged; layout_vbox.PackStart (hb, false, false, 0); layout_vbox.PackStart (white_border = new CheckButton (Catalog.GetString ("White borders")), false, false, 0); white_border.Toggled += TriggerChanged; layout_frame.Child = layout_vbox; Attach (layout_frame, 1, 2, 1, 2); Frame cmt_frame = new Frame (Catalog.GetString ("Custom Text")); cmt_frame.Child = custom_text = new Entry (); Attach (cmt_frame, 1, 2, 2, 3); Frame detail_frame = new Frame (Catalog.GetString ("Photos infos")); VBox detail_vbox = new VBox(); detail_vbox.PackStart (print_filename = new CheckButton (Catalog.GetString ("Print file name")), false, false, 0); detail_vbox.PackStart (print_date = new CheckButton (Catalog.GetString ("Print photo date")), false, false, 0); detail_vbox.PackStart (print_time = new CheckButton (Catalog.GetString ("Print photo time")), false, false, 0); detail_vbox.PackStart (print_tags = new CheckButton (Catalog.GetString ("Print photo tags")), false, false, 0); detail_vbox.PackStart (print_comments = new CheckButton (Catalog.GetString ("Print photo comment")), false, false, 0); detail_frame.Child = detail_vbox; Attach (detail_frame, 0, 1, 2, 4); TriggerChanged (this, null); }
private void OnPrint(object sender, EventArgs arguments){ PrintOperation printing = new PrintOperation(); List<LabelRenderer> labels = new List<LabelRenderer>(); foreach(Model.Item item in Inventory.Items){ Product p = item as Product; if(p != null && p.LabelMethod == LabelMethod.Print){ labels.Add(new LabelRenderer(item,Inventory.Settings.LabelLayout)); } } int labelsPerPage = Inventory.Settings.PageLayout.LabelsPerPage; int currentLabel = 0; printing.BeginPrint += delegate (object obj, Gtk.BeginPrintArgs args) { printing.NPages = (int)Math.Ceiling( (double)labels.Count/(labelsPerPage)); printing.Unit = Unit.Mm; }; printing.DrawPage += delegate (object obj, Gtk.DrawPageArgs args) { PrintContext context = args.Context; using(Context cr = context.CairoContext){ // scale down the cairo context // //context.DpiY, Pango.Layout layout = context.CreatePangoLayout(); ArrayList pageLabels = new ArrayList(); // it is impossible that we have 0 items, otherwise the page would be empty do { pageLabels.Add(labels[currentLabel]); ++currentLabel; } while (currentLabel%labelsPerPage != 0 && currentLabel < labels.Count-1); PageRenderer page = new PageRenderer(pageLabels,Inventory.Settings.PageLayout); page.Render(cr,layout,0,0,context.Width,context.Height); } }; printing.Run (PrintOperationAction.PrintDialog, (Gtk.Window)this.Toplevel); }
public CustomPrintWidget (PrintOperation print_operation) : base () { this.print_operation = print_operation; HBox upper = new HBox (); preview_image = new Gtk.Image (); upper.PackStart (preview_image, false, false, 0); Frame page_size = new Frame (Catalog.GetString ("Page Setup")); VBox vb = new VBox (); Label current_settings = new Label (); if (FSpot.Global.PageSetup != null) current_settings.Text = String.Format (Catalog.GetString ("Paper Size: {0} x {1} mm"), print_operation.DefaultPageSetup.GetPaperWidth (Unit.Mm), print_operation.DefaultPageSetup.GetPaperHeight (Unit.Mm)); else current_settings.Text = String.Format (Catalog.GetString ("Paper Size: {0} x {1} mm"), "...", "..."); vb.PackStart (current_settings, false, false, 0); Button page_setup_btn = new Button ("Set Page Size and Orientation"); page_setup_btn.Clicked += delegate { this.print_operation.DefaultPageSetup = Print.RunPageSetupDialog (null, print_operation.DefaultPageSetup, this.print_operation.PrintSettings); current_settings.Text = String.Format (Catalog.GetString ("Paper Size: {0} x {1} mm"), print_operation.DefaultPageSetup.GetPaperWidth (Unit.Mm), print_operation.DefaultPageSetup.GetPaperHeight (Unit.Mm)); }; vb.PackStart (page_setup_btn, false, false, 0); page_size.Add (vb); VBox right_vb = new VBox (); right_vb.PackStart (page_size, true, true, 0); Frame ppp_frame = new Frame (Catalog.GetString ("Photos per page")); vb = new VBox (); vb.PackStart (ppp1 = new RadioButton ("1"), false, false, 0); vb.PackStart (ppp2 = new RadioButton (ppp1, "2"), false, false, 0); vb.PackStart (ppp4 = new RadioButton (ppp1, "4"), false, false, 0); vb.PackStart (ppp9 = new RadioButton (ppp1, "9"), false, false, 0); // ppp1.Toggled += TriggerChanged; // ppp2.Toggled += TriggerChanged; // ppp4.Toggled += TriggerChanged; // ppp9.Toggled += TriggerChanged; vb.PackStart (repeat = new CheckButton (Catalog.GetString ("Repeat")), false, false, 0); vb.PackStart (crop_marks = new CheckButton (Catalog.GetString ("Print cut marks")), false, false, 0); // crop_marks.Toggled += TriggerChanged; ppp_frame.Child = vb; right_vb.PackStart (ppp_frame, true, true, 0); upper.PackStart (right_vb, true, true, 0); this.PackStart (upper, true, true, 0); this.PackStart (fullpage = new CheckButton (Catalog.GetString ("Full Page (no margin)")), false, false, 0); HBox hb = new HBox (); // Note for translators: "Zoom" is a Fit Mode hb.PackStart (zoom = new RadioButton (Catalog.GetString ("Zoom")), false, false, 0); hb.PackStart (fill = new RadioButton (zoom, Catalog.GetString ("Fill")), false, false, 0); hb.PackStart (scaled = new RadioButton (zoom, Catalog.GetString ("Scaled")), false, false, 0); this.PackStart (hb, false, false, 0); zoom.Toggled += TriggerChanged; fill.Toggled += TriggerChanged; scaled.Toggled += TriggerChanged; this.PackStart (white_border = new CheckButton (Catalog.GetString ("White borders")), false, false, 0); white_border.Toggled += TriggerChanged; hb = new HBox (); hb.PackStart (new Label (Catalog.GetString ("Custom Text: ")), false, false, 0); hb.PackStart (custom_text = new Entry (), true, true, 0); this.PackStart (hb, false, false, 0); TriggerChanged (this, null); }
/// <summary> /// Альтернативная релализация печати, специально для обхода бага в кайро при поворачивании(со старой реализацией печати пол Linux) /// https://bugzilla.mozilla.org/show_bug.cgi?id=1205854#c16 /// В новой при установке ориентации для каждой странице на большенстве принтеров обрезается часть выходящая за поворот. Хотя ориентация правильная. /// На некоторых принтерах например в водовозе, табличка рисуется за вертикалью листа а текст нет. /// используется только на винде, в линуксе такой проблемы нет. /// </summary> private static void PrintAll_Win_Workaround(IEnumerable<IPrintableDocument> documents) { PrintOperation printOp; var documentsRDL_Portrait = documents.Where(doc => doc.PrintType==PrinterType.RDL && doc.Orientation == DocumentOrientation.Portrait).ToList(); var documentsRDL_Landscape = documents.Where(doc=>doc.PrintType==PrinterType.RDL && doc.Orientation == DocumentOrientation.Landscape).ToList(); if (documentsRDL_Portrait.Count > 0) { printOp = new PrintOperation(); printOp.Unit = Unit.Points; printOp.UseFullPage = true; printOp.ShowProgress = true; printOp.DefaultPageSetup = new PageSetup(); printOp.DefaultPageSetup.Orientation = PageOrientation.Portrait; BatchRDLRenderer renderer = new BatchRDLRenderer(documentsRDL_Portrait); var result = LongOperationDlg.StartOperation( renderer.PrepareDocuments, "Подготовка к печати портретных страниц...", documentsRDL_Portrait.Count() ); if (result == LongOperationResult.Canceled) return; printOp.NPages = renderer.PageCount; printOp.DrawPage += renderer.DrawPage; printOp.Run(PrintOperationAction.PrintDialog, null); } if(documentsRDL_Landscape.Count > 0) { printOp = new PrintOperation(); printOp.Unit = Unit.Points; printOp.UseFullPage = true; printOp.ShowProgress = true; printOp.DefaultPageSetup = new PageSetup(); printOp.DefaultPageSetup.Orientation = PageOrientation.Landscape; BatchRDLRenderer renderer = new BatchRDLRenderer(documentsRDL_Landscape); var result = LongOperationDlg.StartOperation( renderer.PrepareDocuments, "Подготовка к печати альбомных страниц...", documentsRDL_Landscape.Count() ); if (result == LongOperationResult.Canceled) return; printOp.NPages = renderer.PageCount; printOp.DrawPage += renderer.DrawPage; printOp.Run(PrintOperationAction.PrintDialog, null); } }
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); } }