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


C# PrintDocument.Dispose方法代码示例

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


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

示例1: createXmlApp

        //如下的这个方法可以注释掉,没有任何的作用
        public void createXmlApp()
        {
            // 首先创建文件
            FileStream fs = File.Create(Application.StartupPath + "\\xmlAPP.xml");
            fs.Close();//关闭文件

            //创建 XmlDocument 以便操作
            XmlDocument xmlDoc = new XmlDocument();

            //xml 唯一的根,我设置的根都是root
            XmlElement xmlEleRoot = xmlDoc.CreateElement("root");

            // 这个配置还有一个是必须的,就是打印机的DPI, 其他的都不是必要的
            XmlElement xmlElePrinter = xmlDoc.CreateElement("printer");

            //打印机名称,这里直接设置默认打印机
            PrintDocument printDoc = new PrintDocument();
            xmlElePrinter.SetAttribute("PrinterName", printDoc.PrinterSettings.PrinterName);
            printDoc.Dispose();//释放资源

            //DPI有两个
            xmlElePrinter.SetAttribute("DPIX", "600");
            xmlElePrinter.SetAttribute("DPIY", "600");

            //如下是两个添加操作了
            xmlEleRoot.AppendChild(xmlElePrinter);
            xmlDoc.AppendChild(xmlEleRoot);

            //保存操作
            xmlDoc.Save(Application.StartupPath + "\\xmlAPP.xml");
        }
开发者ID:kerwinxu,项目名称:barcodeManager,代码行数:32,代码来源:ClsXmlAPP.cs

示例2: Debito

        public void Debito(string debitoID)
        {
            string today = DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year;

            SqlDataReader q = dbc.query_single("SELECT  c.CL_NOMBRE, r.DEBITOID ,r.PRESTAMOID ,CONVERT(VARCHAR(15), r.HE_FECHA, 105)  AS FECHA ,r.CL_CODIGO ,(r.HE_MONTO + r.HE_DESC + r.HE_MORA) As CUOTA ,r.HE_OBSERV FROM  debitos  r inner join clientes c on (c.CL_CODIGO=r.CL_CODIGO ) where DEBITOID=" + debitoID);
            if (q.Read())
            {
                rlines[0] = company;
                rlines[1] = String.Format("{0} \t\t\t\t\t Fecha: {1}", address, q["FECHA"].ToString());
                rlines[2] = string.Format("Tel.: {0}, Cel.: {1}", phone, cell);
                rlines[3] = "____________________________________________ ";
                rlines[4] = "\t\t\tRecibo De Debito ";
                rlines[5] = "Recibo No.: " + q["DEBITOID"].ToString() + " Fecha.: " + q["FECHA"].ToString() + " Prestamo.: " + q["PRESTAMOID"].ToString() + " Cliente.: " + q["CL_CODIGO"].ToString();
                rlines[6] = "Nombre.......: " + q["CL_NOMBRE"].ToString();
                string[] cuotastr = q["CUOTA"].ToString().Split('.'); // split the quota into whole amount and cents
                long monto = long.Parse(cuotastr[0]);
                string montocent = cuotastr[1];
                rlines[7] = String.Format("Monto Ingreso: {0}Pesos Con {1}/100", Number2Word(monto), montocent).ToUpper();
                rlines[8] = "RD$..........: " + q["CUOTA"].ToString();
                rlines[9] = "Concepto.....: " + q["HE_OBSERV"].ToString();
                rlines[10] = "Valido Si Esta Debidamente Firmado y Cellado\t\t\t____________________";
                rlines[11] = "1. Original Cliente / 2. Caja Ingreso / 3. Expediente Cliente";

                /// print data
                PrintDocument pd = new PrintDocument();
                // set printing document margins
                pd.DefaultPageSettings.Margins.Top = 25;
                pd.DefaultPageSettings.Margins.Left = 25;
                pd.DefaultPageSettings.Margins.Right = 25;
                pd.PrintPage += new PrintPageEventHandler(Recibo_PrintPage);
                // Print the document.
                pd.Print();
                pd.Dispose();
            }
            q.Close();

            //  return lines;
        }
开发者ID:papi83dm,项目名称:JMSistemaPrestamo,代码行数:38,代码来源:PrintDoc.cs

示例3: PrintBarcode2

        /// <summary>
        /// 这个方法是充满打印
        /// </summary>
        /// <param name="printDetails"></param>
        private void PrintBarcode2(queuePrintItem printDetails)
        {
            //深度拷贝,因为在打印事件中需要调用这个方法
            currentQueueItem = ClsXmlSerialization.DeepCopy<queuePrintItem>(printDetails);

            Shapes myShapes;
            //首先也是取得纸张的行数和列数
            try
            {
                myShapes = ClsXmlSerialization.Load<Shapes>(currentQueueItem.ShapesFileName);
            }
            catch (System.Exception ex)
            {
                return;//如果不能取得,那么就直接返回

            }

            int intNumOfLine = myShapes.BarcodePageSettings.BarcodePaperLayout.NumberOfLine;
            int intNumOfColumn = myShapes.BarcodePageSettings.BarcodePaperLayout.NumberOfColumn;

            while ((currentQueueItem.IntCount > 0))
            {
                //如下的才能打印
                if (!isprintDocument_PrintPage)
                {
                    //如下的就是具体构造每一个printDocument了
                    myPrintDocument = new PrintDocument();
                    myPrintDocument.DefaultPageSettings.Landscape = myShapes.BarcodePageSettings.BarcodePaperLayout.LandScape;//设置是否横向
                    int intP = ((queuePrintItemRowAndPages)currentQueueItem.arrlistqueuePrintItemRowAndPages[0]).intPages;
                    //设置多少张纸,这个打印份数只是一个数据的,因为如果第一个没有充满纸张,那么就没必要多份了。
                    intPrintPage = (int)(intP / (intNumOfLine * intNumOfColumn));
                    if (intPrintPage == 0)//有时候会出现不足一张的情况
                        intPrintPage = 1;

                    //根据纸张的连续等问题
                    //设置打印机
                    if (strPrinterName != "")
                    {
                        myPrintDocument.PrinterSettings.PrinterName = strPrinterName;
                    }

                    myPrintDocument.PrintController = new StandardPrintController();//这个据说可以不显示那个打印进度对框框
                    myPrintDocument.DocumentName = "打印条形码";//设置完后可在打印对话框及队列中显示(默认显示document)
                    //打印输出(过程)
                    myPrintDocument.PrintPage += new PrintPageEventHandler(myPrintDocument_PrintPage);

                    myPrintDocument.OriginAtMargins = false;//从位于可打印区域的左上角打印
                    //必须得设置自定义纸张,要不然会存在顶点问题,比如说有些条形啊打印机的打印宽度为4英寸,而实际纸张宽度不是4英寸,就会存在打印时候顶点是打印机的顶点,而不是实际纸张的顶点。
                    myPrintDocument.DefaultPageSettings.PaperSize = myShapes.BarcodePageSettings.BarcodePaperLayout.BarcodePaperSize;//设置纸张
                    //如下是设置边距
                    /**如下的经测试会产生不可预测的偏移
                    myPrintDocument.DefaultPageSettings.Margins.Top = (int)(barcodeCanvas.myShapes.BarcodePageSettings.BarcodePaperLayout.Top / 0.254);
                    myPrintDocument.DefaultPageSettings.Margins.Bottom = (int)(barcodeCanvas.myShapes.BarcodePageSettings.BarcodePaperLayout.Bottom / 0.254);
                    myPrintDocument.DefaultPageSettings.Margins.Left = (int)(barcodeCanvas.myShapes.BarcodePageSettings.BarcodePaperLayout.Left / 0.254);
                    myPrintDocument.DefaultPageSettings.Margins.Right = (int)(barcodeCanvas.myShapes.BarcodePageSettings.BarcodePaperLayout.Right / 0.254);

                     * */
                    //每次打印
                    myPrintDocument.PrinterSettings.Copies = (short)intPrintPage;//首先就是一次性全部打印完毕,设置份数就是页数.
                    if (myPrintDocument.PrinterSettings.MaximumCopies < intPrintPage)//如果最高能打印的份数比要打印的页数少,就按照最高能打印的份数.
                        myPrintDocument.PrinterSettings.Copies = (short)myPrintDocument.PrinterSettings.MaximumCopies;

                    //如果能多份打印,就需要提前删掉那些,比如说要打印5个,每张纸可以打印2个,那么这里第一次的份数就是2,但是在打印进程中只会减少2个,会造成重复打印
                    ((queuePrintItemRowAndPages)currentQueueItem.arrlistqueuePrintItemRowAndPages[0]).intPages = ((queuePrintItemRowAndPages)currentQueueItem.arrlistqueuePrintItemRowAndPages[0]).intPages - (myPrintDocument.PrinterSettings.Copies - 1) * (intNumOfLine * intNumOfColumn);

                    try
                    {
                        isprintDocument_PrintPage = true;
                        myPrintDocument.Print();
                        //这里发出打印消息。
                        //isprintDocument_PrintPage = true;// 因为上一个打印进程也需要时间,所以这里先设置了。
                        myPrintDocument.Dispose();//释放

                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("没有打印成功,原因:" + ex.Message);
                        isprintDocument_PrintPage = false;
                        return;
                    }

                }
            }

            //保存打印记录,这里用比较省事的方法
            ClsDataBase myClsDataBase = new ClsDataBase();
            foreach (queuePrintItemRowAndPages item in printDetails.arrlistqueuePrintItemRowAndPages)
            {
                myClsDataBase.commandAddPrintedRecord(printDetails.strTableName, item.arrlistRow, item.intPages);
                OnBarcodePrinted(new printedEventArgs());//发出打印消息

            }
        }
开发者ID:kerwinxu,项目名称:barcodeManager,代码行数:97,代码来源:ClsBarcodePrint.cs

示例4: populateVariable


//.........这里部分代码省略.........
                barcodeCanvas.Loader(ShapeFileName);//先加载模板

            }
            catch (Exception ex)
            {
                ClsErrorFile.WriteLine("不能加载模板,所以不能打印", ex);

                MessageBox.Show("不能加载模板,所以不能打印,原因是"+ ex.Message);

                return 0;
                //throw;
            }

            barcodeCanvas.setArrKeyValue(arrlist);//这个是导入变量用。

            int intNumOfLine = barcodeCanvas.myShapes.BarcodePageSettings.BarcodePaperLayout.NumberOfLine;
            int intNumOfColumn = barcodeCanvas.myShapes.BarcodePageSettings.BarcodePaperLayout.NumberOfColumn;

            myPrintDocument.DefaultPageSettings.Landscape = barcodeCanvas.myShapes.BarcodePageSettings.BarcodePaperLayout.LandScape;//设置是否横向

            //设置多少张纸
            intPrintPage = (int)(intPage / (intNumOfLine*intNumOfColumn));
            if ((intPage %( intNumOfLine*intNumOfColumn)) != 0)//如果不能整除就多一张纸
                intPrintPage++;
            if (intPrintPage == 0)//有时候会出现不足一张的情况
                intPrintPage = 1;

            int intQty = intPrintPage * intNumOfLine*intNumOfColumn;
            //如上是计算了要打印多少页,因为有些条形码纸一行有多个,需要在这里打印。

            //根据纸张的连续等问题
            //设置打印机
            if (strPrinterName!="")
            {
                myPrintDocument.PrinterSettings.PrinterName = strPrinterName;
            }

            myPrintDocument.PrintController = new StandardPrintController();//这个据说可以不显示那个打印进度对框框
            myPrintDocument.DocumentName = "打印条形码";//设置完后可在打印对话框及队列中显示(默认显示document)
            //打印输出(过程)
            myPrintDocument.PrintPage += new PrintPageEventHandler(printDocument_PrintPage);

            myPrintDocument.OriginAtMargins = false ;//从位于可打印区域的左上角打印
            //必须得设置自定义纸张,要不然会存在顶点问题,比如说有些条形啊打印机的打印宽度为4英寸,而实际纸张宽度不是4英寸,就会存在打印时候顶点是打印机的顶点,而不是实际纸张的顶点。
            myPrintDocument.DefaultPageSettings.PaperSize = barcodeCanvas.myShapes.BarcodePageSettings.BarcodePaperLayout.BarcodePaperSize;//设置纸张
            //如下是设置边距
            /**如下的经测试会产生不可预测的偏移
            myPrintDocument.DefaultPageSettings.Margins.Top = (int)(barcodeCanvas.myShapes.BarcodePageSettings.BarcodePaperLayout.Top / 0.254);
            myPrintDocument.DefaultPageSettings.Margins.Bottom = (int)(barcodeCanvas.myShapes.BarcodePageSettings.BarcodePaperLayout.Bottom / 0.254);
            myPrintDocument.DefaultPageSettings.Margins.Left = (int)(barcodeCanvas.myShapes.BarcodePageSettings.BarcodePaperLayout.Left / 0.254);
            myPrintDocument.DefaultPageSettings.Margins.Right = (int)(barcodeCanvas.myShapes.BarcodePageSettings.BarcodePaperLayout.Right / 0.254);

             * */
            //每次打印
            myPrintDocument.PrinterSettings.Copies = (short)intPrintPage;//首先就是一次性全部打印完毕,设置份数就是页数.
            if (myPrintDocument.PrinterSettings.MaximumCopies < intPrintPage)//如果最高能打印的份数比要打印的页数少,就按照最高能打印的份数.
                myPrintDocument.PrinterSettings.Copies = (short)myPrintDocument.PrinterSettings.MaximumCopies;

            try
            {
                isprintDocument_PrintPage = true;

                myPrintDocument.Print();
                //这里发出打印消息。

                myPrintDocument.Dispose();//释放

            }
            catch (Exception ex)
            {
                MessageBox.Show("没有打印成功,原因:" + ex.Message);
                isprintDocument_PrintPage = false;
                return 0;
            }

            //如下是判断是否需要打印间隔
            if (isPrintJiange)
            {
                PrintDocument printDocPrintJianGe = new PrintDocument();
                printDocPrintJianGe.PrintController = new StandardPrintController();
                printDocPrintJianGe.DocumentName = "打印间隔";
                printDocPrintJianGe.PrinterSettings.Copies = 1;// 间隔只打一份。
                printDocPrintJianGe.PrintPage += new PrintPageEventHandler(printDocPrintJianGe_PrintPage);

                try
                {
                    printDocPrintJianGe.Print();
                    printDocPrintJianGe.Dispose();//释放资源

                }
                catch (Exception ex)
                {
                    MessageBox.Show("没有打印成功,原因:" + ex.Message);
                    return 0;
                }

            }

            return intQty;//返回实际打印的数量
        }
开发者ID:kerwinxu,项目名称:barcodeManager,代码行数:101,代码来源:ClsBarcodePrint.cs

示例5: FormSameSize

        /// <summary>
        /// Whether pageheight and pagewidth of the form are same with the specific ones
        /// </summary>
        public static bool FormSameSize(string PrinterName, string FormName, decimal Width, decimal Height)
        {
            bool bolRet = false;

            System.Drawing.Printing.PrintDocument pd = new System.Drawing.Printing.PrintDocument();

            pd.PrinterSettings.PrinterName = PrinterName;

            foreach (System.Drawing.Printing.PaperSize ps in pd.PrinterSettings.PaperSizes)
            {
                if (ps.PaperName == FormName)
                {
                    decimal decWidth = FromInchToCM(System.Convert.ToDecimal(ps.Width));
                    decimal decHeight = FromInchToCM(System.Convert.ToDecimal(ps.Height));

                    if (System.Math.Round(decWidth, 0) == System.Math.Round(Width, 0) && System.Math.Round(decHeight, 0) == System.Math.Round(Height, 0))
                        bolRet = true;
                    break;
                }
            }

            pd.Dispose();

            return bolRet;
        }
开发者ID:TjcJose,项目名称:Hi,代码行数:28,代码来源:Printer.cs

示例6: FormInPrinter

        /// <summary>
        /// Whether the specific form is in the selected printer
        /// </summary>
        public static bool FormInPrinter(string PrinterName, string PaperName)
        {
            bool bolRet = false;

            System.Drawing.Printing.PrintDocument pd = new System.Drawing.Printing.PrintDocument();

            pd.PrinterSettings.PrinterName = PrinterName;

            foreach (System.Drawing.Printing.PaperSize ps in pd.PrinterSettings.PaperSizes)
            {
                if (ps.PaperName == PaperName)
                {
                    bolRet = true;
                    break;
                }
            }

            pd.Dispose();

            return bolRet;
        }
开发者ID:TjcJose,项目名称:Hi,代码行数:24,代码来源:Printer.cs

示例7: button17_Click

        private void button17_Click(object sender, EventArgs e)
        {
            PrintDocument PD = new PrintDocument();
            PD.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage);

            PrintPreviewDialog pdlg = new PrintPreviewDialog();
            pdlg.Document = PD;
            pdlg.ShowDialog();

            try
            {
                PD.Print();
            }
            catch
            {
                Console.WriteLine("Yazici çiktisi alinamiyor...");
            }
            finally
            {
                PD.Dispose();
            }
        }
开发者ID:slymnkbdyi,项目名称:c-sharp,代码行数:22,代码来源:Form1.cs

示例8: PrintPreviewDLG

        public PrintPreviewDLG(DataTable tblMatrix, DataTable tblVocab)
        {
            InitializeComponent();

            this.PrintPreviewCtrl.Paint += PrintPreviewCtrl_Paint;
            this.ZoomFitPageRadio.CheckedChanged += ZoomRadio_CheckedChanged;
            this.ZoomWidthRadio.CheckedChanged += ZoomRadio_CheckedChanged;

            this.PrinterTDdl.Items.Clear();

            // Do not do the Printer Setup Stuff in Visual Studio Design Mode
            if (!System.Reflection.Assembly.GetExecutingAssembly().Location.Contains("VisualStudio"))
            {
                // Load the Printer Selection List
                foreach (string sPrinterName in System.Drawing.Printing.PrinterSettings.InstalledPrinters)
                {
                    this.PrinterTDdl.Items.Add(sPrinterName);
                }
                this.PrinterTDdl.SelectedIndex = -1;
                if (this.PrinterTDdl.SelectedIndex < 0)
                {
                    // Set the Selected Printer to the Default System Printer
                    System.Drawing.Printing.PrintDocument pd = new System.Drawing.Printing.PrintDocument();
                    this.PrinterTDdl.SelectedIndex = this.PrinterTDdl.Items.IndexOf(pd.PrinterSettings.PrinterName);
                    pd.Dispose();
                }
            }
            Layout_ToolBars();

            if (System.Reflection.Assembly.GetExecutingAssembly().Location.Contains("VisualStudio"))
            {
                // Abort if IDE Design Mode
                return;
            }

            m_MatrixTbl = tblMatrix.Copy();
            ReportTools.ReportXPropertiesAdd(ref m_MatrixTbl, true, 0.0f, "CM", 0.0f, 0.0f, 0.0f, 0.0f, "");

            m_VocabTbl = tblVocab.Copy();
            ReportTools.ReportXPropertiesAdd(ref m_VocabTbl, true, 0.0f, "CM", 0.0f, 0.0f, 0.0f, 0.0f, "");

            // Default Page Settings
            XPageSettings = new PrinterSettings().DefaultPageSettings;
            XPageSettings.Margins = new Margins(50, 50, 50, 50);
            XPageSettings.Landscape = false;

            this.PrintTBtn.Visible = true;

            this.Width = Convert.ToInt32(Application.OpenForms[0].Width * 0.80);
            this.Height = Convert.ToInt32(Application.OpenForms[0].Height * 0.80);

            // Generate the Preview
            Preview_Puzzle();
        }
开发者ID:ajstadlin,项目名称:KoWordSearch,代码行数:54,代码来源:PrintPreviewDLG.cs

示例9: DoPrint

        private void DoPrint()
        {
            PrintDocument printDocument = null;
            try
            {
                Status = PrintJobStatus.Printing;
                OnStatusUpdate("Printing Started");

                var printerSettings = new PrinterSettings
                                          {
                                              PrinterName = "Microsoft XPS Document Writer",
                                              PrintToFile = true,
                                              PrintFileName =
                                                  string.Format(
                                                      "{0}\\{1}.xps",
                                                      FullPrintJobFolder,
                                                      SOPInstanceUID.UID)
                                          };

                printDocument = new PrintDocument
                                    {
                                        PrinterSettings = printerSettings,
                                        DocumentName = Thread.CurrentThread.Name,
                                        PrintController = new StandardPrintController()
                                    };

                printDocument.QueryPageSettings += OnQueryPageSettings;
                printDocument.PrintPage += OnPrintPage;

                printDocument.Print();

                Status = PrintJobStatus.Done;

                OnStatusUpdate("Printing Done");
            }
            catch
            {
                Status = PrintJobStatus.Failure;
                OnStatusUpdate("Printing failed");
            }
            finally
            {
                if (printDocument != null)
                {
                    //dispose the print document and unregister events handlers to avoid memory leaks
                    printDocument.QueryPageSettings -= OnQueryPageSettings;
                    printDocument.PrintPage -= OnPrintPage;
                    printDocument.Dispose();
                }
            }
        }
开发者ID:fo-dicom,项目名称:fo-dicom-samples,代码行数:51,代码来源:PrintJob.cs

示例10: Prestamo

        public void Prestamo(string prestamoID)
        {
            string today = DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year;

            SqlDataReader q = dbc.query_single("SELECT  c.CL_NOMBRE, p.PRESTAMOID ,CONVERT(VARCHAR(15), p.CO_FECHA, 105)  AS FECHA ,p.CL_CODIGO,p.CO_CAPITAL, p.CO_INTERES,p.CO_CANPAG, p.CO_TIPPAG  FROM  prestamos  p inner join clientes c on (c.CL_CODIGO=p.CL_CODIGO ) where p.PRESTAMOID=" + prestamoID);
            if (q.Read())
            {
                double cuotafija = GenPrestamoCuotas(q["CO_CAPITAL"].ToString(), q["CO_INTERES"].ToString(), q["CO_CANPAG"].ToString(), q["CO_TIPPAG"].ToString(), q["FECHA"].ToString());
                plines[0] = String.Format(company);
                plines[1] = String.Format("{0} \t\t\t\t\t Fecha: {1}",address, q["FECHA"].ToString());
                plines[2] = String.Format("Tel.: {0}, Cel.: {1}",phone,cell);
                plines[3] = String.Format("____________________________________________ ");
                plines[4] = String.Format("\t\t\tTABLA DE AMORTIZACION ");
                plines[5] = String.Format("Numero De Prestamo..: {0}", q["PRESTAMOID"].ToString());
                plines[6] = String.Format("Codigo Cliente......: {0}\t{1}",q["CL_CODIGO"].ToString(),q["CL_NOMBRE"].ToString());
                plines[7] = String.Format("Fecha...............: {0}", q["FECHA"].ToString());
                plines[8] = String.Format("Capital.............: {0:N}", Double.Parse(q["CO_CAPITAL"].ToString()));
                plines[9] = String.Format("Taza De Interes.....: {0} %", q["CO_INTERES"].ToString());
                plines[10] = String.Format("Cantidad De Cuotas.: {0:F0}", Double.Parse(q["CO_CANPAG"].ToString()));
                plines[11] = String.Format("Forma De Pago......: {0}",getTypo(q["CO_TIPPAG"].ToString()));
                plines[12] = String.Format("Gasto Legales %....:  ");
                plines[13] = String.Format("Cuota Fija.........: {0:N}", cuotafija);
                plines[14] = String.Format("FECHA {0,12}{1,15}{2,10}{3,14}{4,10}", "No.Cuota", "Capital", "Interes", "Total Cuota", "Balance");
                plines[15] = String.Format("__________ __________ ______________ ___________ ______________ ____________");

                /// print data
                PrintDocument pd = new PrintDocument();
                // set printing document margins
                pd.DefaultPageSettings.Margins.Top = 25;
                pd.DefaultPageSettings.Margins.Left = 25;
                pd.DefaultPageSettings.Margins.Right = 25;
                pd.PrintPage += new PrintPageEventHandler(Prestamo_PrintPage);
                // Print the document.

                pd.Print();

                pd.Dispose();
            }
            q.Close();

            //  return lines;
        }
开发者ID:papi83dm,项目名称:JMSistemaPrestamo,代码行数:42,代码来源:PrintDoc.cs

示例11: PrintMenuClick

 /// <summary>
 /// The action of [print] menu click.
 /// show SelectPluginDialog of PluginManager and select the plugin.
 /// </summary>
 /// <param name="sender">object(ToolStripMenuItem)</param>
 /// <param name="e">EventArgs</param>
 private void PrintMenuClick(object sender, EventArgs e)
 {
     PrintPluginDialog d = new PrintPluginDialog(m_env.PluginManager);
     DialogResult result = d.ShowDialog();
     if (result == DialogResult.OK)
     {
         if (d.SelectedItem.Plugin.IsDirect())
         {
             d.SelectedItem.Plugin.Print(d.SelectedItem.Portion);
             d.Dispose();
             return;
         }
         PrintDocument pd = new PrintDocument();
         PrintDialog pdlg = new PrintDialog();
         pdlg.Document = pd;
         pdlg.AllowSomePages = true;
         if (pdlg.ShowDialog() == DialogResult.OK)
         {
             pd.PrintPage += delegate(object o, PrintPageEventArgs pe)
             {
                 Bitmap bmp = new Bitmap(d.SelectedItem.Plugin.Print(d.SelectedItem.Portion), pe.PageBounds.Width, pe.PageBounds.Height);
                 pe.Graphics.DrawImage(bmp, new Point(0, 0));
                 bmp.Dispose();
             };
             pd.Print();
         }
         pd.Dispose();
     }
     d.Dispose();
 }
开发者ID:ecell,项目名称:ecell3-ide,代码行数:36,代码来源:MainWindow.cs

示例12: printToolStripMenuItem_Click

 private void printToolStripMenuItem_Click(object sender, EventArgs e)
 {
     System.Drawing.Printing.PrintDocument doc = new System.Drawing.Printing.PrintDocument();
     doc.DefaultPageSettings.Landscape = true;
     doc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(doc_PrintPage);
     printDialog1.Document = doc;
     if (printDialog1.ShowDialog() == DialogResult.OK)
     {
         doc.Print();
     }
     doc.Dispose();
 }
开发者ID:narzul,项目名称:ADCFTDI,代码行数:12,代码来源:Form1.cs

示例13: DoPrint

        private void DoPrint()
        {
            try
            {
                Status = PrintJobStatus.Printing;
                OnStatusUpdate("Printing Started");

                var printerSettings = new PrinterSettings
                {
                    PrinterName = "Microsoft XPS Document Writer",
                    PrintToFile = true,
                    PrintFileName = string.Format("{0}\\{1}.xps", FullPrintJobFolder, SOPInstanceUID.UID)
                };

                _printDocument = new PrintDocument
                {
                    PrinterSettings = printerSettings,
                    DocumentName = Thread.CurrentThread.Name,
                    //PrintController = new StandardPrintController()
                };

                _printDocument.PrinterSettings.Collate = true;
                _printDocument.PrinterSettings.Copies = (short)Session.NumberOfCopies;
                _printDocument.QueryPageSettings += OnQueryPageSettings;
                _printDocument.PrintPage += OnPrintPage;

                PreviewProc();

                // I would use some kind of if statement below in a production environment and flow a variable
                //throught to the sever to triger it "_preview"
                //if (_preview)
                //    PreviewProc(printDocument);
                //else
                //    printDocument.Print();

                Status = PrintJobStatus.Done;

                OnStatusUpdate("Printing Done");
            }
            catch
            {
                Status = PrintJobStatus.Failure;
                OnStatusUpdate("Printing failed");
            }
            finally
            {
                if (_printDocument != null)
                {
                    //dispose the print document and unregister events handlers to avoid memory leaks
                    _printDocument.QueryPageSettings -= OnQueryPageSettings;
                    _printDocument.PrintPage -= OnPrintPage;
                    _printDocument.Dispose();
                }
            }
        }
开发者ID:GMZ,项目名称:fo-dicom,代码行数:55,代码来源:PrintJob.cs

示例14: Print

        private void Print()
        {
            PrintDialog printDialog = new PrintDialog();
            PrintDocument printImage = new PrintDocument();

            printImage.DocumentName = "Cropper Captured Image";
            printImage.PrintPage += OnPrintPage;

            printDialog.Document = printImage;

            DialogResult result = printDialog.ShowDialog();

            // Send print message
            try
            {
                if (result == DialogResult.OK)
                    printImage.Print();
            }
            catch (InvalidPrinterException)
            {
                ShowPrintError();
            }
            finally
            {
                printImage.Dispose();
                printDialog.Dispose();
            }
        }
开发者ID:pusp,项目名称:o2platform,代码行数:28,代码来源:PrinterOutput.cs

示例15: Print

        public void Print( bool preview )
        {
            if( curr == null )
                return;

            curr.DoOperation( GUI.View.EditOperation.SelectNone );

            PrintDocument pd = new PrintDocument();
            pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
            pd.DefaultPageSettings.Landscape = true;
            pd.DocumentName = curr.name;
            pd.DefaultPageSettings.Margins = new Margins( 25,25,25,25 );
            pages_printed = 0;

            PrintDialog d = new PrintDialog();
            d.Document = pd;
            DialogResult res = d.ShowDialog();

            if( res != DialogResult.OK )
                return;

            pd.PrinterSettings = d.PrinterSettings;

            if( preview ) {
                PrintPreviewDialog ppd = new PrintPreviewDialog();
                ppd.Document = pd;
                ppd.ShowDialog();
            } else {
                pd.Print();
            }

            pd.Dispose();
        }
开发者ID:inspirer,项目名称:uml-designer,代码行数:33,代码来源:ViewCtrl.cs


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