当前位置: 首页>>代码示例>>C#>>正文


C# PrintDocument.Print方法代码示例

本文整理汇总了C#中System.Drawing.Printing.PrintDocument.Print方法的典型用法代码示例。如果您正苦于以下问题:C# PrintDocument.Print方法的具体用法?C# PrintDocument.Print怎么用?C# PrintDocument.Print使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Drawing.Printing.PrintDocument的用法示例。


在下文中一共展示了PrintDocument.Print方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MenuFilePrintOnClick

        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();
        }
开发者ID:xs2ranjeet,项目名称:13ns9-1spr,代码行数:33,代码来源:PrintThreePages.cs

示例2: NetworkPrint

        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)
            {

            }
        }
开发者ID:Jusharra,项目名称:RMS,代码行数:26,代码来源:CPrintMethods.cs

示例3: Printing

        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();

                }
            }
        }
开发者ID:liorg,项目名称:DesignPatternsForXrm,代码行数:26,代码来源:PrintDocumentMethod.cs

示例4: 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();

                }
            }



        }
开发者ID:neyosuraj,项目名称:thisistestRepository,代码行数:28,代码来源:orderlist.cs

示例5: 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();
                }
            }
        }
开发者ID:hydrohead,项目名称:MWSZonBarcode,代码行数:30,代码来源:Printing.cs

示例6: Printing

        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)
            {

            }
        }
开发者ID:sikisuti,项目名称:gyorok,代码行数:33,代码来源:printService.cs

示例7: 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();
        }
开发者ID:FOSBOS,项目名称:diNo,代码行数:35,代码来源:UserControlChecks.cs

示例8: Print

        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
            }
        }
开发者ID:k11hao,项目名称:mdcm-printscp,代码行数:35,代码来源:NPrintService.cs

示例9: 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();
            }
        }
开发者ID:ssementsov,项目名称:PrintBook,代码行数:27,代码来源:PdfPrint.cs

示例10: print

 private void print()
 {
     PrintDocument pd = new PrintDocument();
     pd.PrinterSettings.PrinterName = printerComboBox.SelectedItem.ToString();
     pd.PrintPage += new PrintPageEventHandler (pd_PrintPage);
     pd.Print();
 }
开发者ID:frachstudia,项目名称:studies,代码行数:7,代码来源:Printer.cs

示例11: Printing

        // 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);
            }
        }
开发者ID:yuanrex2012,项目名称:S1-Payment-Operator-Service,代码行数:30,代码来源:Printer.cs

示例12: printButton_Click

        // 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);
                }
            }
        }
开发者ID:CS499Group6,项目名称:PIMS,代码行数:35,代码来源:PrintInfo.cs

示例13: button1_Click

        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!");
            }
        }
开发者ID:Erdemozdemir,项目名称:Sinema-otomasyon,代码行数:31,代码来源:Form1.cs

示例14: printTicket

 public void printTicket()
 {
     PrintDocument pd = new PrintDocument();
     pd.PrintController = new StandardPrintController();
     pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
     pd.Print();
 }
开发者ID:koalas8,项目名称:OpenPOS,代码行数:7,代码来源:TicketsPrinter.cs

示例15: axWindowsMediaPlayer1_PlayStateChange

        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();

            }
        }
开发者ID:marcommas,项目名称:videoAlstomCSharp,代码行数:25,代码来源:Login.cs


注:本文中的System.Drawing.Printing.PrintDocument.Print方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。