Exemple #1
0
        /**
         * This Dispose is called from the Dispose and the Destructor.
         * When disposing==true all non-managed resources should be freed too!
         */

        protected virtual void Dispose(bool disposing)
        {
            if (disposing)
            {
                _printDocument?.Dispose();
                _printDialog?.Dispose();
            }
            _surface       = null;
            _printDocument = null;
            _printDialog   = null;
        }
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                Settings.Default.PrintPageMargins   = printDocument.DefaultPageSettings.Margins;
                Settings.Default.PrintPageLandscape = printDocument.DefaultPageSettings.Landscape;
                Settings.Default.Save();

                Controller?.SaveSettings();

                printDocument?.Dispose();
                components?.Dispose();
            }
            base.Dispose(disposing);
        }
Exemple #3
0
        public static int getPrinterHeight(string sPrinter)
        {
            int iSize = 0;

            PrintDocument pd = new PrintDocument();

            pd.PrinterSettings.PrinterName = sPrinter;

            if (pd.DefaultPageSettings.Landscape)
            {
                iSize = pd.DefaultPageSettings.PaperSize.Width;
            }
            else
            {
                iSize = pd.DefaultPageSettings.PaperSize.Height;
            }

            pd.Dispose();
            return(iSize);
        }
Exemple #4
0
        /// <summary>
        /// 在制定打印机上打印输出内容
        /// </summary>
        /// <param name="_parameters">打印内容列表</param>
        /// <param name="printerName">打印机名称</param>
        /// <param name="errMessage">错误消息,如果有</param>
        /// <returns>成功true否则false</returns>
        public bool Print(List <WinPrinterParameter> _parameters, String printerName, int _width, ref String errMessage)
        {
            bool          isok     = false;
            PrintDialog   dialog   = null;
            PrintDocument document = null;

            try
            {
                dialog   = new PrintDialog();
                document = new PrintDocument()
                {
                    DocumentName = "Pos"
                };
                document.PrinterSettings.PrinterName = printerName;
                document.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0);
                document.PrintController             = new StandardPrintController();
                document.PrintPage += (obj, e) =>
                {
                    isok = PrintContent(_parameters, 0, e, _width);
                };
                dialog.Document = document;
                document.Print();
                isok = true;
            }
            catch (Exception ex)
            {
                errMessage = ex.ToString();
            }
            finally
            {
                if (document != null)
                {
                    document.Dispose();
                }
                if (dialog != null)
                {
                    dialog.Dispose();
                }
            }
            return(isok);
        }
Exemple #5
0
        /// <summary>
        /// 打印数据集
        /// </summary>
        /// <param name="table">数据集</param>
        /// <returns></returns>
        public Boolean PrintDataTable(DataTable table)
        {
            PrintDocument prtDocument = new PrintDocument();

            try
            {
                if (printName != String.Empty)
                {
                    prtDocument.PrinterSettings.PrinterName = printName;
                }
                //prtDocument.DefaultPageSettings.Landscape = true;//设置打印方向为横向
                prtDocument.OriginAtMargins = false;
                PrintDialog prtDialog = new PrintDialog();
                prtDialog.AllowSomePages = true;
                prtDialog.ShowHelp       = false;
                prtDialog.Document       = prtDocument;
                if (DialogResult.OK != prtDialog.ShowDialog())
                {
                    return(false);
                }
                printedTable = table;
                pindex       = 0;
                curdgi       = 0;
                width        = new Int32[printedTable.Columns.Count];
                pheight      = prtDocument.PrinterSettings.DefaultPageSettings.Bounds.Bottom + 400;
                //pheight = prtDocument.PrinterSettings.DefaultPageSettings.Bounds.Bottom;
                pWidth = prtDocument.PrinterSettings.DefaultPageSettings.Bounds.Right;
                prtDocument.PrintPage += new PrintPageEventHandler(docToPrint_PrintPage);
                prtDocument.Print();
            }
            catch (InvalidPrinterException ex)
            {
                MessageBox.Show("没有安装打印机");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            prtDocument.Dispose();
            return(true);
        }
        private bool PrintItemBarcodeLabel()
        {
            bool bPrint = false;

            try
            {
                //设置文档名
                printdoc.DocumentName = tbProductNo.Text.Trim();//设置完后可在打印对话框及队列中显示(默认显示document)

                //打印开始前
                printdoc.BeginPrint += new PrintEventHandler(printDocument_BeginPrint);
                //打印输出(过程)
                printdoc.PrintPage += new PrintPageEventHandler(ExcutPrintLabel);
                //打印结束
                printdoc.EndPrint += new PrintEventHandler(printDocument_EndPrint);

                printdoc.PrinterSettings.PrinterName = cbPrinter.SelectedItem.ToString();

                /////打印时隐藏弹出 正在打印
                printdoc.PrintController = new StandardPrintController();
                if (!printdoc.PrinterSettings.IsValid)
                {
                    //找不到打印机则不打印,报错返回。
                    bPrint = false;
                }
                else
                {
                    printdoc.Print();          //打印
                    printdoc.Dispose();

                    printdoc = new PrintDocument();
                    bPrint   = true;
                }
            }
            catch (Exception ex)
            {
                bPrint = false;
            }

            return(bPrint);
        }
Exemple #7
0
        /// <summary>
        /// Set the printer defaults and generate a page of cells
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdGenerate_Click(object sender, EventArgs e)
        {
            lblStatus.Text = "Generating...";
            useCartesian   = true;
            Stopwatch sw = new Stopwatch();

            sw.Start();

            GenerateCartesian();
            if (Cartesian.Count() == 0)
            {
                if (pages == 0)
                {
                    lblStatus.Text = "Your filtering criteria have returned zero results.  Please adjust and re-try.";
                }
                else
                {
                    lblStatus.Text = "Your filtering criteria has not generated any further pages.  Please adjust and re-try";
                }
                return;
            }

            PrintDocument pd = new PrintDocument();

            pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);

            pd.PrinterSettings.DefaultPageSettings.PrinterResolution.X = Constants.DPI;
            pd.PrinterSettings.DefaultPageSettings.PrinterResolution.Y = Constants.DPI;
            pd.PrinterSettings.PrinterName = PrinterName;

            Debug.Print(string.Format("Count: {0}, Columns: {1}, Rows: {2}", Cartesian.Count(), Constants.NumColumns, Constants.NumRows));

            pd.Print();
            pd.Dispose();

            sw.Stop();
            Debug.Print(string.Format("Print took {0} sec.", sw.Elapsed.TotalSeconds));

            pages++;
            lblStatus.Text = "Completed";
        }
Exemple #8
0
        public static void printTxtFile1(string FName)
        {
            PrintDialog1                  = new PrintDialog();
            PrintDialog1.UseEXDialog      = true;
            PrintDialog1.AllowPrintToFile = false;
            PrintDialog1.AllowCurrentPage = false;
            PrintDialog1.AllowSelection   = false;
            PrintDialog1.AllowSomePages   = false;
            printFont = new Font("Arial", 10f);
            var pd = new PrintDocument();

            pd.PrintPage         += pd_PrintPage;
            pd.DocumentName       = FName;
            PrintDialog1.Document = pd;
            if (PrintDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    streamToPrint = new System.IO.StreamReader(FName);
                    try
                    {
                        // printFont = New Font("Arial", 10)
                        // Dim pd As New PrintDocument()
                        // AddHandler pd.PrintPage, AddressOf pd_PrintPage
                        pd.Print();
                    }
                    finally
                    {
                        streamToPrint.Close();
                    }
                }
                catch (Exception ex)
                {
                    System.Windows.MessageBox.Show(ex.Message);
                }
            }

            PrintDialog1.Dispose();
            pd.Dispose();
            return;
        }
Exemple #9
0
        //What happens when you click the print button
        private void repPrintButton_Click(object sender, EventArgs e)
        {
            repSaveButton_Click(null, null);

            if (whatPath == 1)
            {
                printFilePath = employeePath + selectedEmployee + ".txt";
            }
            else if (whatPath == 2)
            {
                printFilePath = employerPath + selectedEmployer + ".txt";
            }
            else if (whatPath == 3)
            {
                printFilePath = evalPath + evalFilePath + ".txt";
            }
            else if (whatPath == 4)
            {
                printFilePath = fieldPath + fieldPlacementFilePath + ".txt";
            }

            PrintDocument printDoc = new PrintDocument();

            printDoc.PrintPage += new PrintPageEventHandler(PrintPage);
            PrintDialog printDiagBox = new PrintDialog();

            printFont             = new System.Drawing.Font("Arial", 10);
            printDiagBox.Document = printDoc;
            if (printDiagBox.ShowDialog() == DialogResult.OK)
            {
                printDoc.DocumentName = printFilePath;
                printDoc.Print();
            }

            else
            {
                MessageBox.Show("Cancelled the print job.");
            }
            printDiagBox.Dispose();
            printDoc.Dispose();
        }
Exemple #10
0
        /// <summary>
        /// 获取指定打印机的所有盒子(纸张来源)可选项
        /// </summary>
        /// <param name="PrinterName">打印机名称</param>
        /// <returns>盒子可选项列表</returns>
        public static List <string> GetPrinterBoxs(string PrinterName)
        {
            PrintDocument printDocument      = new PrintDocument();
            string        defaultPrinterName = printDocument.PrinterSettings.PrinterName;

            printDocument.PrinterSettings.PrinterName = PrinterName;

            List <string> list = new List <string>();
            PaperSource   paperSource;

            for (int i = 0; i < printDocument.PrinterSettings.PaperSources.Count; i++)
            {
                paperSource = printDocument.PrinterSettings.PaperSources[i];
                list.Add(paperSource.SourceName);
            }
            printDocument.PrinterSettings.PrinterName = defaultPrinterName;

            printDocument.Dispose();

            return(list);
        }
 /**
  * This Dispose is called from the Dispose and the Destructor.
  * When disposing==true all non-managed resources should be freed too!
  */
 protected void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (image != null)
         {
             image.Dispose();
         }
         if (printDocument != null)
         {
             printDocument.Dispose();
         }
         if (printDialog != null)
         {
             printDialog.Dispose();
         }
     }
     image         = null;
     printDocument = null;
     printDialog   = null;
 }
 private void button1_Click(object sender, EventArgs e)
 {
     if (pd != null)
     {
         pd.Dispose();
     }
     else
     {
         pd = new PrintDocument();
     }
     printFont = new Font("Arial", 10);
     //linesCount = Schiessabend.Rows.Count;
     //pd = new PrintDocument();
     pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
     printPreviewControl1.Document = pd;
     button2.Enabled = true;
     //PrintPreviewDialog pvd = new PrintPreviewDialog();
     //pvd.Document = pd;
     //pvd.ShowDialog();
     //pd.Print();
 }
Exemple #13
0
        /// <summary>
        /// Whether the specific form is in the selected printer
        /// </summary>
        public static bool FormInPrinter(string PrinterName, string PaperName)
        {
            bool bolRet = false;

            PrintDocument pd = new PrintDocument();

            pd.PrinterSettings.PrinterName = PrinterName;

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

            pd.Dispose();

            return(bolRet);
        }
Exemple #14
0
    static void Main(string[] args)
    {
        dosyaAkimi = new System.IO.StreamReader("C:\\Data.mdb");

        PrintDocument PD = new PrintDocument();

        PD.PrintPage += new PrintPageEventHandler(OnPrintDocument);

        try
        {
            PD.Print();
        }
        catch
        {
            Console.WriteLine("Yazici çiktisi alinamiyor...");
        }
        finally
        {
            PD.Dispose();
        }
    }
Exemple #15
0
        private void printlabel()
        {
            PrintDocument doc = new PrintDocument();

            doc.PrintPage += this.Doc_PrintPage;

            doc.DefaultPageSettings.PaperSize = new PaperSize("100 x 50 mm", 393, 196);


            if (printstatus)
            {
                doc.Print();
                doc.Dispose();
            }
            else
            {
                PrintPreviewDialog pd = new PrintPreviewDialog();
                pd.Document = doc;
                pd.ShowDialog();
            }
        }
        // Handler for print call
        private void ButtonPrintClick()
        {
            // Create document
            PrintDocument _document = new PrintDocument();

            // Add print handler
            _document.PrintPage += new PrintPageEventHandler(Document_PrintPage);
            // Create the dialog to display results
            PrintPreviewDialog _dlg = new PrintPreviewDialog();

            _dlg.ClientSize   = new System.Drawing.Size(Width / 2, Height / 2);
            _dlg.Location     = new System.Drawing.Point(Left, Top);
            _dlg.MinimumSize  = new System.Drawing.Size(375, 250);
            _dlg.UseAntiAlias = true;
            // Setting up our document
            _dlg.Document = _document;
            // Show it
            _dlg.ShowDialog(this);
            // Dispose document
            _document.Dispose();
        }
Exemple #17
0
        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;
        }
        private void Drawprint(string PrinterName)
        {
            try
            {
                using (PrintDocument print = new PrintDocument())
                {
                    print.PrintPage += new PrintPageEventHandler(PrintPage);

                    print.PrinterSettings.PrinterName   = PrinterName;
                    print.DefaultPageSettings.Landscape = true;

                    print.PrinterSettings.Duplex = Duplex.Simplex;

                    print.Print();
                    print.Dispose();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #19
0
        public static void PrintScreen(Rectangle ScrBounds)
        {
            PrintDialog1                  = new PrintDialog();
            PrintDialog1.UseEXDialog      = true;
            PrintDialog1.AllowPrintToFile = false;
            PrintDialog1.AllowCurrentPage = false;
            PrintDialog1.AllowSelection   = false;
            PrintDialog1.AllowSomePages   = false;
            PrtDoc            = new PrintDocument();
            PrtDoc.PrintPage += PrtDoc_PrintPage;

            // Dim area As Rectangle
            Bitmap   capture;
            Graphics graph;

            // area = ScrBounds
            capture    = new Bitmap(ScrBounds.Width, ScrBounds.Height); // System.Drawing.Imaging.PixelFormat.Format32bppArgb)
            graph      = Graphics.FromImage(capture);
            graph.Clip = new Region(ScrBounds);
            graph.CopyFromScreen(ScrBounds.X, ScrBounds.Y, 0, 0, ScrBounds.Size); // CopyPixelOperation.SourceCopy)
            if (My.MyProject.Computer.FileSystem.FileExists(PrtFileName))
            {
                My.MyProject.Computer.FileSystem.DeleteFile(PrtFileName);
            }

            capture.Save(PrtFileName);
            PrtDoc.DocumentName   = PrtFileName;
            PrintDialog1.Document = PrtDoc;
            if (PrintDialog1.ShowDialog() == DialogResult.OK)
            {
                PrtDoc.Print();
            }

            graph.Dispose();
            capture.Dispose();
            PrintDialog1.Dispose();
            PrtDoc.Dispose();
            return;
        }
Exemple #20
0
        public void spoolrec(string documento)
        {
            try
            {
                streamToPrint = new StreamReader
                                    (documento, false);
                printFont = new Font("Arial", 9);
                PrintDocument pd = new PrintDocument();
                pd.PrintPage += new PrintPageEventHandler
                                    (this.pd_PrintPage);
                pd.PrintController = new System.Drawing.Printing.StandardPrintController();
                pd.Print();
                streamToPrint.Close();
                pd.Dispose();
            }


            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        public void PrintLable()
        {
            PrintDocument           pd        = new PrintDocument();
            StandardPrintController controler = new StandardPrintController();

            try
            {
                pd.PrintPage      += new PrintPageEventHandler(this.PrintCustomLable);
                pd.PrintController = controler;
                pd.Print();
                return;
            }
            catch (Exception err)
            {
                Console.WriteLine(err.Message);
                return;
            }
            finally
            {
                pd.Dispose();
            }
        }
Exemple #22
0
        internal void PrintLabel(string address, string value, /*string descUPS,*/ bool international)
        {
            Debug.WriteLine("PrinterApi: PrintLebel");
            string[] info = address.Split(new char[] { '\n' }, 2);

            _printLabelDoc = new PrintDocument();
            PaperSize pS = new PaperSize("Lable Size", _propSet.LABEL_PRINTER_PAPER_WIDTH, _propSet.LABEL_PRINTER_PAPER_HEIGHT);

            _printLabelDoc.DefaultPageSettings.PaperSize = pS;
            _printLabelDoc.PrinterSettings.PrinterName   = _propSet.LABEL_PRINTER;
            _printLabelDoc.PrinterSettings.DefaultPageSettings.PaperSize = pS;
            _printLabelDoc.PrintPage += (sender, e) => Label_PrintPage(e.Graphics, info[0], info[1], value, /*descUPS,*/ international);
            try
            {
                _printLabelDoc.Print();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
            _printLabelDoc.Dispose();
        }
Exemple #23
0
        public void PrintGiftCertificate(string NameOnCertificate, double Amount, int GiftCertificateID, Bitmap barcode)
        {
            PrintDocument labelDoc;

            nameOnCertificate     = NameOnCertificate;
            giftCertificateID     = GiftCertificateID;
            giftCertificateAmount = Amount;
            barcodeToPrint        = barcode;

            // Create the document and name it
            labelDoc = new PrintDocument();
            labelDoc.DocumentName = "Gift Certificate";
            labelDoc.DefaultPageSettings.Landscape = true;

            labelDoc.PrintPage += new PrintPageEventHandler(this.printGiftCertificate);

            PaperSize paperSize = new PaperSize("GiftCertificate", 1100, 850); //full 8.5 x 11 page

            //PaperSize paperSize = new PaperSize("Label", 83, 366);
            labelDoc.DefaultPageSettings.PaperSize = paperSize;

            Margins margins = new Margins(5, 5, 5, 5);

            labelDoc.DefaultPageSettings.Margins = margins;

#if DEBUG
            // Preview document
            System.Windows.Forms.PrintPreviewDialog printPreviewDialog1 = new System.Windows.Forms.PrintPreviewDialog();
            printPreviewDialog1.Document = labelDoc;
            printPreviewDialog1.ShowDialog();
#else
            //print with no preview
            labelDoc.Print();
#endif

            //Dispose of document when done printing
            labelDoc.Dispose();
        }
Exemple #24
0
        // Protected implementation of Dispose pattern.
        /// <summary>
        ///  Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposed)
            {
                return;
            }

            if (disposing && (components != null))
            {
                components.Dispose();
                //if (streamToPrint != null) streamToPrint.Dispose();
                if (printDoc != null)
                {
                    printDoc.Dispose();
                }
                if (printPreview != null)
                {
                    printPreview.Dispose();
                }
            }
            disposed = true;
            base.Dispose(disposing);
        }
        public void imprimirFactura(string detalle)
        {
            this.detalle = detalle;

            if (detalle.Contains("ITBIS"))
            {
                fecha = "FACTURA CON VALOR FISCAL\nRNC: 131-993923\nFECHA: " + DateTime.Now.ToString() + "\n";
            }

            recordDoc.DocumentName    = "Factura";
            recordDoc.PrintPage      += new PrintPageEventHandler(PrintReceiptPage);
            recordDoc.PrintController = new StandardPrintController();
            //ps.PrinterName = "POS-58";
            recordDoc.PrinterSettings = ps;
            //recordDoc.Print();
            PrintPreviewDialog printPrvDlg = new PrintPreviewDialog();

            printPrvDlg.Document = recordDoc;
            printPrvDlg.Width    = 1000;
            printPrvDlg.Height   = 400;
            printPrvDlg.ShowDialog();
            recordDoc.Dispose();
        }
Exemple #26
0
        private void imprimePreviewDeCSharp()
        {
            PrintPreviewDialog printPreviewDialog1 = new PrintPreviewDialog();
            PrintDocument      printDocument1      = new PrintDocument();

            printDocument1.PrintPage    += new PrintPageEventHandler(OnPrintDocument);
            printPreviewDialog1.Document = printDocument1;

            printPreviewDialog1.Document.DocumentName = pathsDictionary["plantillaHallazgos"];
            printPreviewDialog1.ShowDialog();
            try
            {
                printDocument1.Print();
            }
            catch
            {
                MessageBox.Show("Yazıcı çıktısı alınamıyor...");
            }
            finally
            {
                printDocument1.Dispose();
            }
        }
Exemple #27
0
 private void button2_Click(object sender, EventArgs e)
 {
     {
         /* print function from here https://stackoverflow.com/questions/10605840/print-panel-in-windows-form-c-sharp*/
         // Create document
         PrintDocument _document = new PrintDocument();
         // Add print handler
         _document.PrintPage += new PrintPageEventHandler(Document_PrintPage);
         // Create the dialog to display results
         PrintPreviewDialog _dlg = new PrintPreviewDialog();
         _dlg.ClientSize   = new System.Drawing.Size(Width / 2, Height / 2);
         _dlg.Location     = new System.Drawing.Point(Left, Top);
         _dlg.MinimumSize  = new System.Drawing.Size(375, 400);
         _dlg.UseAntiAlias = true;
         // Setting up our document
         _dlg.Document = _document;
         // Show it
         _dlg.ShowDialog(this);
         // Dispose document
         _document.Dispose();
     }
     // Print handler
 }
Exemple #28
0
 public void PrintOut(string printerName, List <t_pos_printer_out> listPrint)
 {
     if (((listPrint != null) && (listPrint.Count != 0)) && !string.IsNullOrEmpty(printerName))
     {
         this._listPrint = listPrint;
         try
         {
             PrintDialog   dialog   = new PrintDialog();
             PrintDocument document = new PrintDocument {
                 DocumentName = "POS机小票"
             };
             document.PrinterSettings.PrinterName = printerName;
             document.DefaultPageSettings.Margins = new Margins(0, 0, 0, 0);
             document.PrintController             = new StandardPrintController();
             if (PrintMorePage)
             {
                 document.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.PrintPageEventHandler2);
             }
             else
             {
                 document.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.PrintPageEventHandler);
             }
             dialog.Document = document;
             document.Print();
             document.Dispose();
             dialog.Dispose();
         }
         catch (InvalidPrinterException exception)
         {
             MessageBox.Show(exception.Message, "系统提示");
         }
         catch (Exception exception2)
         {
             MessageBox.Show(exception2.Message, "系统提示");
         }
     }
 }
Exemple #29
0
        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();
            }
        }
Exemple #30
0
        private void printlabel(String module)
        {
            PrintDocument doc = new PrintDocument();

            if (module.Equals("packing"))
            {
                doc.PrintPage += this.Doc_PrintPage_packing;
                doc.DefaultPageSettings.PaperSize = new PaperSize("100 x 150 mm", 393, 590);
            }
            else if (module.Equals("retouching"))
            {
                doc.PrintPage += this.Doc_PrintPage_retouching;
                doc.DefaultPageSettings.PaperSize = new PaperSize("100 x 50 mm", 393, 196);
            }

            /*
             * PrintPreviewDialog pd = new PrintPreviewDialog();
             * pd.Document = doc;
             * pd.ShowDialog();
             */

            doc.Print();
            doc.Dispose();
        }