public void NetworkPrint(LocalReport report, String inPrinterName) { try { string printerName = inPrinterName; Export(report); m_currentPageIndex = 0; PrintDocument printDoc = new PrintDocument(); printDoc.PrinterSettings.PrinterName = printerName; if (!printDoc.PrinterSettings.IsValid) { string msg = String.Format("Can't find printer \"{0}\".", printerName); //MessageBox.Show(msg, "Print Error"); return; } printDoc.PrintPage += new PrintPageEventHandler(PrintPage); printDoc.Print(); } catch (Exception ee) { } }
private static System.Drawing.Printing.PrintDocument printDoc = new System.Drawing.Printing.PrintDocument(); //实例化一个打印的对象 public static void GetPanel(Panel p) { MoveBar(0, 0, p); //下面的方法 MoveBar(1, 0, p); //下面的方法 Point pit = GetScrollPoint(p); //下面的方法 p.Width += pit.X + 5; //滚动条的宽 p.Height += pit.Y + 5; //滚动条的高 bitMap = new Bitmap(p.Width, p.Height); //根据画布的宽和高赋值给位图 p.DrawToBitmap(bitMap, new Rectangle(0, 0, bitMap.Width, bitMap.Height)); PrintPreviewDialog ppvw = new PrintPreviewDialog(); //初始化一个打印预览 ppvw.Width = 800; //设置预览的宽 ppvw.Height = 600; //设置预览的高 ppvw.Document = printDoc; // 预览的文档赋值发送给打印机 printDoc.DefaultPageSettings.Landscape = true; //true-横打,false-纵打 printDoc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage); //打印之前发生的事 PaperSize pp = null; //定义纸张大小为空 foreach (PaperSize ps in ppvw.Document.PrinterSettings.PaperSizes) //获取该打印机支持的纸张大小 { if (ps.PaperName.Equals("A4")) //这里设置纸张大小,但必须是定义好的 { pp = ps; } } ppvw.Document.DefaultPageSettings.PaperSize = pp; //设置纸张的大小为A3 if (ppvw.ShowDialog() != DialogResult.OK) //如果不打印的话,返回 { printDoc.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage); return; } printDoc.Print(); //开始打印 }
public void print() { PrintDialog pd = new PrintDialog(); PrintDocument pdoc = new PrintDocument(); PrinterSettings ps = new PrinterSettings(); Font font =new Font("Arial",12); PaperSize psize = new PaperSize("Custome", 100, 200); pd.Document = pdoc; pd.Document.DefaultPageSettings.PaperSize = psize; pdoc.DefaultPageSettings.PaperSize.Height = 320; pdoc.DefaultPageSettings.PaperSize.Width = 200; pdoc.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage); DialogResult result = pd.ShowDialog(); if (result == DialogResult.OK) { PrintPreviewDialog ppd = new PrintPreviewDialog(); ppd.Document = pdoc; result = ppd.ShowDialog(); if (result == DialogResult.OK) { pdoc.Print(); } } }
public void printDataTable(DataTable dt, PrintInfo p) { this.printDt = dt; this.pInfo = p; PrintDocument pd = new System.Drawing.Printing.PrintDocument(); PrinterSettings pss = new System.Drawing.Printing.PrinterSettings(); pss.DefaultPageSettings.Landscape = pInfo.landscape; pd.PrinterSettings = pss; pd.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(pd_PrintPage); PrintDialog ppd = new PrintDialog(); ppd.Document = pd; if (printDt == null) { MessageBox.Show("出错", "没有可以打印的数据", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (ppd.ShowDialog() == DialogResult.OK) { try { pd.Print(); } catch (Exception ex) { MessageBox.Show("出错", ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public void Printing() { PrintDialog pDialog = new PrintDialog(); FileStream fs = new FileStream(@"Szervíz_Feltételek.txt", FileMode.Open, FileAccess.Read); StreamReader sr = new StreamReader(fs); contract = sr.ReadToEnd(); try { try { PrintDocument pd = new PrintDocument(); pd.PrintPage += new PrintPageEventHandler(pd_PrintRent); if (pDialog.ShowDialog() == DialogResult.OK) { pd.PrinterSettings = pDialog.PrinterSettings; // Print the document. pd.Print(); } } finally { } } catch (Exception ex) { } }
private void btnPrint_Click(object sender, EventArgs e) { pullSchematics(); pageCount = 0; System.Drawing.Printing.PrintDocument doc = new System.Drawing.Printing.PrintDocument(); doc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(CaptureScreen); prtDialog.Document = doc; DialogResult result = prtDialog.ShowDialog(); if (result == DialogResult.OK) { try { doc.DefaultPageSettings.Landscape = false; doc.Print(); } catch (Exception E) { MessageBox.Show(E.Message); } } tbMethodInfo.SelectedIndex = 0; pnlInitControls.Visible = true; DialogResult dr = MessageBox.Show("New comm-code?", "Printing Complete", MessageBoxButtons.YesNo); if (dr == DialogResult.Yes) { btnClear_Click(this, EventArgs.Empty); txtCode.Focus(); } }
public static void Print_DataGridView(DataGridView dgv1) { PrintPreviewDialog ppvw = new PrintPreviewDialog(); try { // Getting DataGridView object to print dgv = dgv1; // Getting all Coulmns Names in the DataGridView AvailableColumns.Clear(); foreach (DataGridViewColumn c in dgv.Columns) { if (!c.Visible) { continue; } AvailableColumns.Add(c.HeaderText); } // Showing the PrintOption Form frmPrintOptions dlg = new frmPrintOptions(AvailableColumns); if (dlg.ShowDialog() == DialogResult.Cancel) { return; } PrintTitle = dlg.PrintTitle; PrintAllRows = dlg.PrintAllRows; FitToPageWidth = dlg.FitToPageWidth; SelectedColumns = dlg.GetSelectedColumns(); RowsPerPage = 0; ppvw = new PrintPreviewDialog(); ppvw.Document = printDoc; // Showing the Print Preview Page printDoc.BeginPrint += new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint); printDoc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage); if (ppvw.ShowDialog() != DialogResult.OK) { printDoc.BeginPrint -= new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint); printDoc.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage); return; } // Printing the Documnet printDoc.Print(); printDoc.BeginPrint -= new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint); printDoc.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { } }
void MenuFilePrintOnClick(object obj, EventArgs ea) { // Create PrintDocument. PrintDocument prndoc = new PrintDocument(); // Create dialog box and set PrinterName property. PrinterSelectionDialog dlg = new PrinterSelectionDialog(); dlg.PrinterName = prndoc.PrinterSettings.PrinterName; // Show dialog box and bail out if not OK. if (dlg.ShowDialog() != DialogResult.OK) return; // Set PrintDocument to selected printer. prndoc.PrinterSettings.PrinterName = dlg.PrinterName; // Set printer resolution to "draft". foreach (PrinterResolution prnres in prndoc.PrinterSettings.PrinterResolutions) { if (prnres.Kind == PrinterResolutionKind.Draft) prndoc.DefaultPageSettings.PrinterResolution = prnres; } // Set remainder of PrintDocument properties. prndoc.DocumentName = Text; prndoc.PrintPage += new PrintPageEventHandler(OnPrintPage); prndoc.QueryPageSettings += new QueryPageSettingsEventHandler(OnQueryPageSettings); // Commence printing. iPageNNumber = 1; prndoc.Print(); }
public void print() { this.printd_pos.PrintController = new System.Drawing.Printing.StandardPrintController(); this.printd_pos.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(printd_pos_PrintPage); //设置边距 Margins margins = new Margins(32, 5, 30, 5); this.printd_pos.DefaultPageSettings.Margins = margins; this.printd_pos.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("First custom size", getYc(78), 600); //this.printDocument1.PrinterSettings.PrinterName = ""; //Margins margins = new Margins( //this.printv_pos.Document = this.printd_pos; printv_pos.PrintPreviewControl.AutoZoom = false; printv_pos.PrintPreviewControl.Zoom = 1; // this.printv_pos.ShowDialog(win); try { printd_pos.Print(); } catch (Exception ex) { printd_pos.PrintController.OnEndPrint(printd_pos, new PrintEventArgs()); } }
/// <summary> /// Handles the Click event of the Print button /// </summary> /// <param name="sender">Object that fired the event</param> /// <param name="e">.NET supplied event parameters</param> private void btnPrint_Click(object sender, EventArgs e) { System.Drawing.Printing.PrintDocument docToPrint = new System.Drawing.Printing.PrintDocument(); docToPrint.PrintPage += new PrintPageEventHandler(docToPrint_PrintPage); PrintDialog dialog = new PrintDialog(); dialog.AllowSelection = true; dialog.Document = docToPrint; DialogResult result = dialog.ShowDialog(); if (result == DialogResult.OK) { try { docToPrint.Print(); } catch (Win32Exception ex) { MsgBox.Show(ex.Message, SharedStrings.MAKE_VIEW); } catch (Exception ex) { MsgBox.ShowException(ex); } } }
/// <summary> /// 打印. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPrint_Click(object sender, EventArgs e) { if (printDialog1.ShowDialog(this) == System.Windows.Forms.DialogResult.OK) { printDocument1.Print(); } }
public void Denpyo(Entity.InputRecord[] st, int dIndex, int pMode) { //伝票データ DenData = st; //現在の伝票 PRINT_Den = dIndex; //プリントモード PrintMode = pMode; //印刷設定 System.Drawing.Printing.PrintDocument PrnDen = new System.Drawing.Printing.PrintDocument(); PrnDen.PrinterSettings = new System.Drawing.Printing.PrinterSettings(); //用紙方向:ヨコ PrnDen.DefaultPageSettings.Landscape = true; //用紙サイズ:A4 foreach (System.Drawing.Printing.PaperSize ps in PrnDen.PrinterSettings.PaperSizes) { if (ps.Kind == System.Drawing.Printing.PaperKind.A4) { PrnDen.DefaultPageSettings.PaperSize = ps; break; } } //印刷実行 PrnDen.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(Denpyo_Print); PrnDen.Print(); }
public void Printing(string pname, string path) { using (IOStream = new FileStream(path, FileMode.Open, FileAccess.Read)) { using (PrintDocument pd = new PrintDocument()) { _qu = new PagingImage(path); pd.PrintPage += new PrintPageEventHandler((sender, ev) => { var img = _qu.GetPage(page); if (img == null) { ev.HasMorePages = false; return; } ev.Graphics.DrawImage(img, ev.Graphics.VisibleClipBounds); page++; ev.HasMorePages = _qu.Max >= page; }); pd.PrinterSettings.PrinterName = pname; pd.Print(); } } }
public static void showInvoiceDialog(IWin32Window target, long tranId) { try { printTranID = tranId; System.Drawing.Printing.PrintDocument pDoc = new System.Drawing.Printing.PrintDocument(); int neededWidth = 600, height = 800; pDoc.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0); pDoc.DefaultPageSettings.PaperSize = new PaperSize("Custom", neededWidth, height); pDoc.DefaultPageSettings.PaperSize.Height = height; pDoc.DefaultPageSettings.PaperSize.Width = neededWidth; pDoc.PrintPage += PDoc_PrintPage; //PrintDialog printDialog = new PrintDialog(); //printDialog.Document = pDoc; PrintPreviewDialog ppDialog = new PrintPreviewDialog(); ppDialog.FindForm().WindowState = FormWindowState.Maximized; ppDialog.Document = pDoc; if (ppDialog.ShowDialog(target) == DialogResult.OK) { pDoc.Print(); } //new forms.frmInvoice(tranId).ShowDialog(target); } catch (Exception ex) { MessageBox.Show(target, "Sorry, error occured please try again after setting default printer in your Printers Setttings." + Environment.NewLine + "Error message : " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
// The Click event is raised when the user clicks the Print button. public void printButton_Click() { dialog.AllowSomePages = true; dialog.ShowNetwork = true; DialogResult result = dialog.ShowDialog(); if (result == DialogResult.OK) { try { streamToPrint = new StreamReader ("MyFile.txt"); try { printFont = new Font("Arial", 10); PrintDocument pd = new PrintDocument(); pd.PrinterSettings.PrinterName = dialog.PrinterSettings.PrinterName; dialog.Document = pd; dialog.Document.PrintPage += new PrintPageEventHandler(pd_PrintPage); pd.Print(); } finally { streamToPrint.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
static void Main(string[] args) { while (true) { StringBuilder sb = new StringBuilder(); Console.WriteLine("Start Sleep 10 seconds"); Thread.Sleep(10000); try { Console.WriteLine("PrintReceptSoapClient start"); POS58Listen.PrintService.OrderDataSoapClient pr = new POS58Listen.PrintService.OrderDataSoapClient(); Console.WriteLine("PrintReceptSoapClient end"); DataSet xx = pr.getPrintOrderData(); dt = xx.Tables[0]; if (dt.Rows.Count > 0) { PrintDocument pd = new System.Drawing.Printing.PrintDocument(); pd.PrintPage += printPageEvent; pd.Print(); y = 0; } } catch (Exception e) { Console.WriteLine(e.Message.ToString()); } } }
/// <summary> /// 打印 /// </summary> public void Print() { try { //allow the user to choose the page range to be printed printDialog1.AllowSomePages = true; //show the help button. printDialog1.ShowHelp = true; //set the Document property to the PrintDocument for which the PrintPage Event //has been handled. To display the dialog, either this property or the //PrinterSettings property must be set printDialog1.Document = document; //show the print dialog and wait for user input DialogResult result = printDialog1.ShowDialog(); // If the result is OK then print the document. if (result == DialogResult.OK) { document.Print(); } } catch { MessageBox.Show("未安装打印机", "提示"); } }
private void button1_Click(object sender, EventArgs e) { if (comboFilmAdi.Text != "" || comboFilmSalon.Text != "" || comboFilmSeans.Text != ""||checkBoxTam.Checked==false||checkBoxOgrenci.Checked==false) { bag.Open(); komut.Connection = bag; komut.CommandText = "SELECT koltuk FROM koltuk_tbl WHERE filmadi='" + comboFilmAdi.Text + "' AND filmsaati='" + comboFilmSeans.Text + "' AND filmsalon='" + comboFilmSalon.Text + "'"; SqlDataReader dr = komut.ExecuteReader(); while (dr.Read()) { string cekilenveri = dr["koltuk"].ToString(); string gonderVeri = cekilenveri + textKoltuk.Text; komut.CommandText = "UPDATE koltuk_tbl SET koltuk='" + gonderVeri + "' WHERE filmadi='" + comboFilmAdi.Text + "' AND filmsaati='" + comboFilmSeans.Text + "' AND filmsalon='" + comboFilmSalon.Text + "'"; } dr.Close(); komut.ExecuteNonQuery(); bag.Close(); textKoltuk.Clear(); //yazıcı çıktı işlemleri PrintDocument pd = new PrintDocument(); pd.PrintPage += new PrintPageEventHandler(pd_PrintPage); pd.Print(); } else { MessageBox.Show("Bos alanlar var!"); } }
private void btnPrint_Click(object sender, System.EventArgs e) { if (Panel2.Controls == null || Panel2.Controls.Count == 0) { MessageBox.Show("没有页面要打印"); return; } PictureBox pic = (PictureBox)this.Panel2.Controls[0]; if (pic == null) { MessageBox.Show("没有页面要打印"); return; } if (this.rdoContinuePrint.Checked || this.rdoPrintSelection.Checked) { if (pic.Controls == null || pic.Controls.Count == 0 || pic.Controls[0].Controls == null || pic.Controls[0].Controls.Count == 0) { MessageBox.Show("请首先选择打印范围"); return; } } System.Drawing.Printing.PrintDocument document = new System.Drawing.Printing.PrintDocument(); document.DefaultPageSettings.PaperSize = new PaperSize(this.pageSize.Name, this.pageSize.Width, this.pageSize.Height); document.DefaultPageSettings.Margins = new Margins(pageSize.Left, pageSize.Left, pageSize.Top, 50); document.BeginPrint += new PrintEventHandler(document_BeginPrint); document.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.document_PrintPage); document.EndPrint += new PrintEventHandler(document_EndPrint); document.Print(); //pic.Controls.Clear(); }
// This method will set properties on the PrintDialog object and // then display the dialog. public void StartPrint(Stream streamToPrint, string streamType) { this.streamToPrint = streamToPrint; this.streamType = streamType; // Allow the user to choose the page range he or she would // like to print. System.Windows.Forms.PrintDialog PrintDialog1 = new PrintDialog();//实现C#打印之创建一个PrintDialog的实例。 PrintDialog1.AllowSomePages = true; // Show the help button. PrintDialog1.ShowHelp = true; // Set the Document property to the PrintDocument for // which the PrintPage Event has been handled. To display the // dialog, either this property or the PrinterSettings property // must be set PrintDialog1.Document = docToPrint; //把PrintDialog的Document属性设为上面配置好的PrintDocument的实例 DialogResult result = PrintDialog1.ShowDialog(); //调用PrintDialog的ShowDialog函数显示打印对话框 // If the result is OK then print the document. if (result == DialogResult.OK) { docToPrint.Print();//实现C#打印之开始打印 } }
/// <summary> /// 数据打印 /// </summary> /// <param name="printData"></param> public virtual void InvoicePrint(PrintDataClass printData) { PrintDocument document = new PrintDocument(); //this.PrintData = printData; Margins margins = new Margins(this.DanToPex(0.5M), this.DanToPex(0.5M), this.DanToPex(0.5M), this.DanToPex(0.5M)); document.DefaultPageSettings.Margins = margins; PaperSize size = new PaperSize("First custom size", this.DanToPex(PageSizeW), this.DanToPex(PageSizeH)); document.DefaultPageSettings.PaperSize = size; document.PrintController = new StandardPrintController(); document.PrintPage += new PrintPageEventHandler(this.pd_PrintPage); try { document.Print(); LogHelper.WriteLog("过磅编号为:" + GetTextDate() + "。数据打印成功!"); } catch (Exception e) { document.PrintController.OnEndPrint(document, new PrintEventArgs()); LogHelper.WriteLog(LogHelper.GetCurSourceFileName() + "~" + LogHelper.GetLineNum() + "打印失败!", e); } finally { this.printData = null; } }
private static void method2(string filename, string printer) { Spire.Doc.Document doc = new Spire.Doc.Document(); doc.LoadFromFile(filename); System.Drawing.Printing.PrintDocument printDoc = doc.PrintDocument; //get the page size SizeF sf = doc.Sections[0].PageSetup.PageSize; float wd = sf.Width; float ht = sf.Height; float a = (S.PageSize.A4.Height - wd) / 2; float b = (S.PageSize.A4.Width - ht) / 2; //set printing margins printDoc.OriginAtMargins = true; //printDoc.DefaultPageSettings.Margins = new System.Drawing.Printing.Margins((int)(a), (int)(a), (int)(b), (int)(b)); printDoc.PrinterSettings.PrinterName = printer; printDoc.PrinterSettings.Duplex = Duplex.Horizontal; printDoc.DefaultPageSettings.PaperSize = new PaperSize("postcard", 600, 400); printDoc.PrintController = new StandardPrintController(); printDoc.Print(); }
private static void method1(string filename, string printer) { Spire.Doc.Document doc = new Spire.Doc.Document(); //Load word document doc.LoadFromFile(filename); //Printing with Custom paper SizeF sf = doc.Sections[0].PageSetup.PageSize; float wd = sf.Width; float ht = sf.Height; System.Drawing.Printing.PrintDocument printDoc = doc.PrintDocument; printDoc.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("custom", (int)wd / 72 * 100, (int)ht / 72 * 100); doc.PrintDocument.PrinterSettings.PrinterName = printer; if (doc.PrintDocument.PrinterSettings.CanDuplex) { //Setting Horizontal printing ; doc.PrintDocument.PrinterSettings.Duplex = Duplex.Horizontal; } System.Drawing.Printing.PrintController printController = new System.Drawing.Printing.StandardPrintController(); printDoc.PrintController = printController; printDoc.Print(); }
//Label finally gets printed through this public void PassUserControl(Panel print, short pages) { try { foreach (Control ctl in print.Controls) { if (ctl is CheckBox && ((CheckBox)(ctl)).Checked == true) { System.Drawing.Printing.PrintDocument doc = new System.Drawing.Printing.PrintDocument(); doc.PrintPage += new PrintPageEventHandler((sender, e) => pd_PrintPage(sender, e, print)); PrintDialog PrintSettings = new PrintDialog(); PrintSettings.Document = doc; //PageSettings pgsetting = new PageSettings(); //PrintPreviewDialog dlgPreview = new PrintPreviewDialog(); //dlgPreview.Document = doc; //dlgPreview.Show(); PrintSettings.PrinterSettings.Copies = pages; //if (PrintSettings.ShowDialog() == DialogResult.OK) doc.Print(); } } } catch (Exception err) { MsgBuilder theBuilder = new MsgBuilder(); theBuilder.DataElements["MessageText"] = err.Message.ToString(); IQCareWindowMsgBox.ShowWindowConfirm("#C1", theBuilder, this); } }
public void Imprimir_etiqueta() { PrinterSettings prtSettings = new PrinterSettings(); prtSettings.DefaultPageSettings.Landscape = false; prtSettings.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("Custom", 384, 192); // 100x50 mm //prtSettings.PrinterName = "IMPRESORA1"; //prtSettings.PrinterName = impresora; //prtSettings.PrinterName = "Adobe PDF"; PrintDocument prtDoc = new System.Drawing.Printing.PrintDocument(); prtDoc.PrintPage += new PrintPageEventHandler(Print_PrintPage); //la configuración a usar en la impresión prtDoc.PrinterSettings = prtSettings; int i = 0; int copias = Convert.ToInt32(copiasBox.Text); while (i < copias) { System.Threading.Thread.Sleep(50); prtDoc.Print(); //System.Threading.Thread.Sleep(200); i++; } //ConexionDB masiva = new ConexionDB(); //masiva.GuardarMasivo(sql_masivo); }
public bool Print(string Text, string FontFamilyName, float FontSize, string printerName) { try { PrinterName = printerName; if (!GetPrinterStatus(printerName)) { throw new ArgumentException("Printer " + printerName + " is currently offline.", "original"); } printingText = Text; printingText = printingText.Replace(Environment.NewLine, "<n>"); printFontDefault = new System.Drawing.Font(FontFamilyName, FontSize); System.Drawing.Printing.PrintDocument pd = new System.Drawing.Printing.PrintDocument(); pd.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(pd_PrintPage); if (PrinterName != "") { pd.PrinterSettings.PrinterName = PrinterName; } pd.Print(); pd.Dispose(); } catch { Debug.LogWarning("Cannot Print!"); return(false); } return(true); }
// Print Event private void miPrint_Click(object sender, System.EventArgs e) { if (printDialog1.ShowDialog() == DialogResult.OK) { printDocument1.Print(); } }
public void Print(List<string> meldungen) { PrintDocument printDocument1 = new PrintDocument(); printDocument1.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage); //this.textBoxKlasse.Text = klasse; this.textBoxDatum.Text = DateTime.Today.ToShortDateString(); foreach (string meldung in meldungen) { var item = new ListViewItem(); if (meldung.StartsWith("Schüler")) { item.Font = new Font(item.Font, FontStyle.Bold); item.Text = meldung; } else { item.Text = " " + meldung; } this.listViewChecks.Items.Add(item); } CaptureScreen(); List<string> Printers = new List<string>(); foreach (string p in PrinterSettings.InstalledPrinters) Printers.Add(p); // Alle verfügbaren Drucker sind in Printers gespeichert, // TODO: man könnte den Benutzer daraus auswählen lassen. // In diesem Beispiel wird einfach immer Drucker 0 gewählt. printDocument1.PrinterSettings.PrinterName = PrinterSettings.InstalledPrinters[0]; printDocument1.Print(); }
public void Print(IList<string> pageStore) { using (var printDocument = new PrintDocument()) { printDocument.PrintController = new StandardPrintController(); printDocument.PrinterSettings.PrinterName = NamePrinter; int index = 0; printDocument.PrintPage += (o, e) => { if (index < pageStore.Count) { using (Image img = Image.FromFile(pageStore[index])) { e.Graphics.DrawImage(img, e.Graphics.VisibleClipBounds); } index++; e.HasMorePages = index < pageStore.Count; } else { e.HasMorePages = false; } }; printDocument.Print(); } }
private void butPrint_Click(object sender,EventArgs e) { PrintDocument pd2=new PrintDocument(); pd2.PrintPage+=new PrintPageEventHandler(this.pd2_PrintPage); pd2.OriginAtMargins=true; pd2.DefaultPageSettings.Margins=new Margins(0,0,0,0); pd2.Print(); }
private void axWindowsMediaPlayer1_PlayStateChange(object sender, _WMPOCXEvents_PlayStateChangeEvent e) { //QUANDO VIDEO FOR PARADO if ( axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsPaused ) { //O VIDEO FOI PARADO, PARA CONTINUAR PRECISA CLICAR EM OK if ( MessageBox.Show("Video Parado. Clique aqui para continuar!", "", MessageBoxButtons.OK , MessageBoxIcon.Information) == DialogResult.OK ) { axWindowsMediaPlayer1.Ctlcontrols.play(); } } //QUANDO O VIDEO ACABAR if (axWindowsMediaPlayer1.playState == WMPLib.WMPPlayState.wmppsMediaEnded) { //IMPRIME PrintDocument document = new PrintDocument(); document.PrintPage += new PrintPageEventHandler(impressaoConf); document.Print(); this.Hide(); } }
public static void Imprimir(Entidades.Álbum.Álbum álbum, ItensImpressão itens) { using (PrintDocument documento = new PrintDocument()) { documento.DocumentName = "Álbum " + álbum.Nome; using (PrintDialog dlg = new PrintDialog()) { dlg.AllowCurrentPage = false; dlg.AllowSelection = false; dlg.AllowSomePages = true; dlg.UseEXDialog = true; dlg.Document = documento; if (dlg.ShowDialog() == DialogResult.OK) { ControleImpressão ctrl = new ControleImpressão(álbum, itens); ctrl.página = new Página( documento.PrinterSettings.DefaultPageSettings.PrintableArea.Width / 100f, documento.PrinterSettings.DefaultPageSettings.PrintableArea.Height / 100f, 4, 5); ctrl.daPágina = dlg.PrinterSettings.FromPage; ctrl.atéPágina = dlg.PrinterSettings.ToPage != 0 ? dlg.PrinterSettings.ToPage : int.MaxValue; documento.PrintPage += new PrintPageEventHandler(ctrl.ImprimirPágina); documento.Print(); } } } }
public void printTicket() { PrintDocument pd = new PrintDocument(); pd.PrintController = new StandardPrintController(); pd.PrintPage += new PrintPageEventHandler(pd_PrintPage); pd.Print(); }
private void button1_Click(object sender, EventArgs e) { PrintDocument pd = new PrintDocument(); pd.PrintPage += PrintPage; pd.Print(); this.Close(); }
public void Print() { try { _current = 0; PrintDocument document = new PrintDocument(); document.PrinterSettings = _config.PrinterSettings; document.PrinterSettings.Collate = true; document.PrinterSettings.Copies = (short)_session.NumberOfCopies; //document.DefaultPageSettings.Margins = new Margins(100, 100, 100, 100); document.DefaultPageSettings.Margins = new Margins(25, 25, 25, 25); document.QueryPageSettings += OnQueryPageSettings; document.PrintPage += OnPrintPage; if (!String.IsNullOrEmpty(_config.PaperSource)) { foreach (PaperSource source in document.PrinterSettings.PaperSources) { if (source.SourceName == _config.PaperSource) document.DefaultPageSettings.PaperSource = source; } } if (_config.PreviewOnly) { if (Application.OpenForms.Count > 0) Application.OpenForms[0].BeginInvoke(new WaitCallback(PreviewProc), document); } else { document.Print(); } } catch (Exception ex) { #if DEBUG Dicom.Debug.Log.Error("DICOM Print Error: " + ex.ToString()); #else Dicom.Debug.Log.Error("DICOM Print Error: " + ex.Message); #endif } }
private void File_Print(object sender, System.EventArgs e) { System.Drawing.Printing.PrintDocument doc = new System.Drawing.Printing.PrintDocument(); doc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(PrintPage); fScribble.Document.WaitForBackgroundAnalysis(); UpdateFileName(); doc.DocumentName = fFileName; doc.PrinterSettings.FromPage = 1; doc.PrinterSettings.ToPage = fScribble.Document.Pages.Count; doc.PrinterSettings.MaximumPage = fScribble.Document.Pages.Count; PrintDialog dialog = new PrintDialog(); dialog.AllowSelection = false; dialog.AllowSomePages = true; dialog.ShowNetwork = true; dialog.Document = doc; doc.OriginAtMargins = true; if (dialog.ShowDialog(this) == DialogResult.OK) { fPrintPhysicalRectangles.Clear(); fPrintPage = dialog.PrinterSettings.FromPage - 1; fPrintRectangle = 0; doc.Print(); } }
//파일 > 인쇄 private void menuFilePrint_Click(object sender, System.EventArgs e) { if (printDialog1.ShowDialog() == DialogResult.OK) //인쇄하기를 선택할 경우 { printDocument1.Print(); //printDocument1을 프린트 시작 } }
public void Run() { PrintDocument doc = new PrintDocument(); doc.PrinterSettings = m_settings; doc.PrintPage += doc_PrintPage; doc.Print(); }
private static void ImprimirEtiq(Microsoft.Reporting.WebForms.LocalReport etiqueta) { using (var pd = new System.Drawing.Printing.PrintDocument()) { //configurar impressora //pd.PrinterSettings.PrinterName = "Microsoft Print to PDF"; pd.PrinterSettings.PrinterName = impressora_etiqueta; var pageSettings = new System.Drawing.Printing.PageSettings(); Margins margins = new Margins(0, 0, 0, 0); var pageSettingsEtiqueta = etiqueta.GetDefaultPageSettings(); pageSettings.PaperSize = pageSettingsEtiqueta.PaperSize; pageSettings.Margins = pageSettingsEtiqueta.Margins; pd.DefaultPageSettings.Margins = margins; //pd.DefaultPageSettings = pageSettings; pd.PrintPage += Pd_PrintPage; _streamAtual = 0; pd.Print(); } }
private static void TestPrint(string x) { //加载图片到Image对象 gbmp = x; System.Drawing.Printing.PrintDocument pd = new System.Drawing.Printing.PrintDocument(); //Refreshpd();// pd.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(pd_PrintPageTest); pd.Print(); }
public void PrintTokens(List<TokenPrint> tokens, Form parentDialog, string PrinterName, bool showPrintPreview) { _tokensToPrint = tokens; _pageCounter = 0; //bool showPrintPreview = true; PrintDocument pd = new PrintDocument(); PrintDocument pd1 = new PrintDocument(); pd.DefaultPageSettings.PaperSize = paperSize; pd.PrintPage += printDoc_PrintPage; pd.PrinterSettings.PrinterName = PrinterName; //ToDo: can remove preview in the actual production. if (showPrintPreview) { var ppDlg = new PrintPreviewDialog(); ppDlg.SetBounds(30, 30, 1024, 500); ppDlg.PrintPreviewControl.AutoZoom = true; ppDlg.PrintPreviewControl.Zoom = 0.75; ppDlg.Document = pd; var dr = ppDlg.ShowDialog(parentDialog); } else { pd.Print(); } }
public bool printImage(string[] imagePaths) { // Get desired image width int desiredImageWidth; if (imagePaths.Count() == 1) { desiredImageWidth = (A4_WIDTH - (gap + 2 * A4_BORDER_WIDTH)); } else { desiredImageWidth = (A4_WIDTH - ((gap + 2 * A4_BORDER_WIDTH) / 2)); } try { List<Image> images = new List<Image>(); foreach (string imagePath in imagePaths) { Image image = Image.FromFile(imagePath); image = this.Scale(image, maxImageWidth, A4_HEIGHT); images.Add(image); } PrintDocument pd = new PrintDocument(); pd.PrintPage += (sender, e) => printDoc_PrintPage(images, sender, e); pd.Print(); } catch (System.Drawing.Printing.InvalidPrinterException) { return false; } return true; }
/* Events to execute when the "Print" button is clicked */ private void Print_button_Click(object sender, EventArgs e) { /* Creates a new instance of printDocument, appends the result from PrintDocumentOnPrintPage and prints the result */ PrintDocument printDocument = new PrintDocument(); printDocument.PrintPage += PrintDocumentOnPrintPage; printDocument.Print(); }
protected virtual PrinterSettings ShowPrintSetupDialog(System.Drawing.Printing.PrintDocument printDocument_1) { this.ThrowPrintDocumentNullException(printDocument_1); PrinterSettings printerSettings = new PrinterSettings(); PrintDialog dialog = new PrintDialog(); try { dialog.AllowSomePages = true; dialog.Document = printDocument_1; if (dialog.ShowDialog() == DialogResult.OK) { printerSettings = dialog.PrinterSettings; printDocument_1.Print(); } } catch (InvalidPrinterException exception) { this.ShowInvalidPrinterException(exception); } catch (Exception exception2) { this.ShowPrinterException(exception2); } finally { dialog.Dispose(); dialog = null; } return(printerSettings); }
public static void PrintOrder() { var doc = new PrintDocument(); doc.PrinterSettings.PrinterName = System.Configuration.ConfigurationManager.AppSettings["PrinterName"]; doc.PrintPage += new PrintPageEventHandler(PrintPage); doc.Print(); }
///<summary></summary> public void PrintReport() { pd2 = new PrintDocument(); pd2.PrintPage += new PrintPageEventHandler(this.pd2_PrintPage); pd2.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0); pd2.OriginAtMargins = true; if (!PrefB.GetBool("RxOrientVert")) { pd2.DefaultPageSettings.Landscape = true; } #if DEBUG pd2.DefaultPageSettings.PaperSize = new PaperSize("default", 850, 1100); pView.printPreviewControl2.Document = pd2; pView.ShowDialog(); #else if (!Printers.SetPrinter(pd2, PrintSituation.Rx)) { return; } try{ pd2.Print(); } catch { MessageBox.Show(Lan.g(this, "Printer not available")); } #endif }
public void StartPrint(T[] values, string printer, bool showPrinterDialog, PrintTemplate template) { if (template == null) { throw new Exception("打印失败参数:template 为空"); } if (values == null) { throw new Exception("打印失败参数:vlaues 为空"); } if (values.Length == 0) { throw new Exception("打印失败参数:vlaues 没有数据"); } if (values.Any(obj => obj == null)) { throw new Exception("打印失败参数:vlaues 中含有空对象"); } System.Drawing.Printing.PrintDocument document = new System.Drawing.Printing.PrintDocument(); if (showPrinterDialog == false) { if (string.IsNullOrWhiteSpace(printer)) { throw new Exception("打印机名称为空,请设置打印机"); } if (System.Drawing.Printing.PrinterSettings.InstalledPrinters.OfType <string>().Contains(printer) == false) { throw new Exception("打印机不存在此电脑上:" + printer); } document.PrinterSettings.PrinterName = printer; } else { var pd = new System.Windows.Forms.PrintDialog() { UseEXDialog = true }; var ret = pd.ShowDialog(); if (ret != System.Windows.Forms.DialogResult.OK && ret != System.Windows.Forms.DialogResult.Yes) { return; } document.PrinterSettings.PrinterName = pd.PrinterSettings.PrinterName; } document.PrintController = new System.Drawing.Printing.StandardPrintController(); document.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("shoperp_print_size", (int)MapToPrinterPix(template.Width), (int)MapToPrinterPix(template.Height)); document.DefaultPageSettings.Margins = new System.Drawing.Printing.Margins(0, 0, 0, 0); document.DocumentName = template.Name + DateTime.Now; document.PrintPage += Document_PrintPage; document.BeginPrint += Document_BeginPrint; document.EndPrint += Document_EndPrint; this.index = 0; this.Values = values; this.Template = template; document.Print(); }
public static void PrintLabel(PrintDocument document) { printDiagLabel.Document = document; if (printDiagLabel.ShowDialog() != DialogResult.OK) return; document.Print(); }
private void button1_Click(object sender, System.EventArgs e) { pd = new PrintDocument(); pd.PrintPage += new PrintPageEventHandler(pd_PrintPage); pd.PrinterSettings.PrinterName = "PDFCreator"; pd.DocumentName = "PDFCreator Dot Net - Sample2"; pd.Print(); }
public void print(MODLEFKINFO modleFK, Image imagept, Image _image2) { modleFKINFO = modleFK; image2 = _image2; imagep = imagept; docToPrint.PrintPage += new PrintPageEventHandler(this.document_PrintPage); docToPrint.Print();//打印 }
private void butPrint_Click(object sender,EventArgs e) { PrintDocument pd=new PrintDocument(); pd.PrintPage += new PrintPageEventHandler(this.pd2_PrintPage); if(PrinterL.SetPrinter(pd,PrintSituation.Default)) { pd.Print(); } }
public static void Print_DataGridView(DataGridView dgv1) { PrintPreviewDialog ppvw; try { // Obtém objecto para imprimir do DataGridView dgv = dgv1; // Obtém todos os nomes das colunas da DataGridView AvailableColumns.Clear(); foreach (DataGridViewColumn c in dgv.Columns) { if (!c.Visible) { continue; } AvailableColumns.Add(c.HeaderText); } // Mostra o form PrintOption PrintOptions dlg = new PrintOptions(AvailableColumns); if (dlg.ShowDialog() != DialogResult.OK) { return; } PrintTitle = dlg.PrintTitle; SelectedColumns = dlg.GetSelectedColumns(); RowsPerPage = 0; ppvw = new PrintPreviewDialog(); ppvw.Document = printDoc; // Mostra o PrintPreview printDoc.BeginPrint += new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint); printDoc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage); if (ppvw.ShowDialog() != DialogResult.OK) { printDoc.BeginPrint -= new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint); printDoc.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage); return; } // Imprime o documento printDoc.Print(); printDoc.BeginPrint -= new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint); printDoc.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { } }
public void Print() { printDialog1.Document = printDocument1; if (showPrintDialog) { printDialog1.ShowDialog(); } printDocument1.Print(); }
public void printWithImage_Click(object sender, EventArgs e) { printImage = true; if (printDialog1.ShowDialog() == DialogResult.OK) { printDialog1.Document = printDocument1; printDocument1.Print(); } }
public void Print(byte[] buffer, int copies = 1) { try { using (var stream = new MemoryStream(buffer)) { _image = Image.FromStream(stream); } _printDocument = new PrintDocument(); IEnumerable<string> printers = GetAvailablePrinters(); string name = printers.FirstOrDefault(x => x.Contains("PDF")); //printer not found if (string.IsNullOrEmpty(name)) return; _printDocument.PrinterSettings.Copies = (short)copies; _printDocument.PrintController = new StandardPrintController(); _printDocument.PrinterSettings.PrinterName = name; _printDocument.BeginPrint += printDocument_BeginPrint; _printDocument.PrintPage += printDocument_PrintPage; _printDocument.Print(); } catch (Exception) { } }
// Print the file. public void Printing(string filePath, string printerName) { try { streamToPrint = new StreamReader(filePath); try { printFont = new Font(fontType, fontSize); PrintDocument pd = new PrintDocument(); pd.PrintPage += new PrintPageEventHandler(pd_PrintPage); pd.PrinterSettings.PrinterName = printerName; pd.DefaultPageSettings.Landscape = true; pd.DefaultPageSettings.PaperSize = paperSize; // Print the document. pd.Print(); } finally { streamToPrint.Close(); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private void butPrint_Click(object sender,EventArgs e) { pagesPrinted=0; PrintDocument pd=new PrintDocument(); pd.PrintPage += new PrintPageEventHandler(this.pd_PrintPage); pd.DefaultPageSettings.Margins=new Margins(25,25,40,40); //pd.OriginAtMargins=true; pd.DefaultPageSettings.Landscape=false; if(pd.DefaultPageSettings.PrintableArea.Height==0) { pd.DefaultPageSettings.PaperSize=new PaperSize("default",850,1100); } headingPrinted=false; try { #if DEBUG FormRpPrintPreview pView = new FormRpPrintPreview(); pView.printPreviewControl2.Document=pd; pView.ShowDialog(); #else if(PrinterL.SetPrinter(pd,PrintSituation.Default)) { pd.Print(); } #endif } catch { MessageBox.Show(Lan.g(this,"Printer not available")); } }
private void print() { PrintDocument pd = new PrintDocument(); pd.PrinterSettings.PrinterName = printerComboBox.SelectedItem.ToString(); pd.PrintPage += new PrintPageEventHandler (pd_PrintPage); pd.Print(); }
public void print() { PrintDialog pd = new PrintDialog(); pdoc = new PrintDocument(); PrinterSettings ps = new PrinterSettings(); Font font = new Font("Courier New", 15); PaperSize psize = new PaperSize("Custom", 300, 100); ps.DefaultPageSettings.PaperSize = psize; pd.Document = pdoc; pd.Document.DefaultPageSettings.PaperSize = psize; pdoc.DefaultPageSettings.PaperSize = psize; pdoc.PrintPage += new PrintPageEventHandler(pdoc_PrintPage); DialogResult result = pd.ShowDialog(); if (result == DialogResult.OK) { PrintPreviewDialog pp = new PrintPreviewDialog(); pp.Document = pdoc; result = pp.ShowDialog(); if (result == DialogResult.OK) { pdoc.Print(); } } }
public void Print(byte[] buffer, string printerName, int copies = 1) { if (string.IsNullOrEmpty(printerName)) return; try { using (var stream = new MemoryStream(buffer)) { _image = Image.FromStream(stream); } _printDocument = new PrintDocument(); _printDocument.PrinterSettings.Copies = (short)copies; _printDocument.PrintController = new StandardPrintController(); _printDocument.PrinterSettings.PrinterName = printerName; _printDocument.BeginPrint += printDocument_BeginPrint; _printDocument.PrintPage += printDocument_PrintPage; _printDocument.Print(); } catch (Exception) { } }