private void printMenuItem_Click(object sender, System.EventArgs e)
 {
     gridPrinter.Prepare_To_Print();
     if (printDialog1.ShowDialog() == DialogResult.OK)
     {
         printDocument1.Print();
     }
 }
        // The printing setup function
        private bool SetupThePrinting()
        {
            PrintDialog MyPrintDialog = new PrintDialog();
               MyPrintDialog.AllowCurrentPage = false;
               MyPrintDialog.AllowPrintToFile = false;
               MyPrintDialog.AllowSelection = false;
               MyPrintDialog.AllowSomePages = false;
               MyPrintDialog.PrintToFile = false;
               MyPrintDialog.ShowHelp = false;
               MyPrintDialog.ShowNetwork = false;

               if (MyPrintDialog.ShowDialog() != DialogResult.OK)
            return false;
               MyPrintDocument.DocumentName = "Planilla de ventas peluquería";
               MyPrintDialog.PrinterSettings.DefaultPageSettings.Landscape = true; //página horizontal
               //MyPrintDialog.PrinterSettings.DefaultPageSettings.Landscape = false; //página vertical
               MyPrintDocument.PrinterSettings = MyPrintDialog.PrinterSettings;
               MyPrintDocument.DefaultPageSettings = MyPrintDialog.PrinterSettings.DefaultPageSettings;
               MyPrintDocument.DefaultPageSettings.Margins = new Margins(40, 40, 40, 40);

               //if (MessageBox.Show("¿Desea centrar el reporte en la pagina?",
               // "InvoiceManager - Center on Page", MessageBoxButtons.YesNo,
               // MessageBoxIcon.Question) == DialogResult.Yes)
               // MyDataGridViewPrinter = new DataGridViewPrinter(MyDataGridView,
               // MyPrintDocument, true, true, "Listado Completo de Facturas", new Font("Tahoma", 15,
               // FontStyle.Bold, GraphicsUnit.Point), Color.Black, true);
               //else
               string encabezado = "Vendedor: Cecilia Toscani             Zona: " + txtZona.Text + "               Fecha: " + DateTime.Now.ToLongDateString();
            MyDataGridViewPrinter = new DataGridViewPrinter(MyDataGridView,
            MyPrintDocument, false, true, encabezado, new Font("Tahoma", 13,
            FontStyle.Bold, GraphicsUnit.Point), Color.Black, true);
               return true;
        }
Пример #3
0
        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)
            {

            }
        }
Пример #4
0
        private Boolean Print()
        {
            Boolean returnValue = default(Boolean);

            System.Windows.Forms.PrintDialog printDialog = new System.Windows.Forms.PrintDialog();
            Boolean?dialogResult = (printDialog.ShowDialog() == DialogResult.OK);

            if (dialogResult.HasValue && dialogResult.Value)
            {
                try
                {
                    //printDialog.PrintVisual(/*_view.ChartControl*/, "app_name");

                    returnValue = true;
                }
                catch (Exception ex)
                {
                    Log.Write(ex, MethodBase.GetCurrentMethod(), EventLogEntryType.Error);

                    throw ex;
                }
            }

            return(returnValue);
        }
Пример #5
0
        /// <summary>
        /// This event displays a printer selection dialog and then starts the print
        /// process.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">An EventArgs that contains the event data.</param>
        private void PrintButton_Click(object sender, System.EventArgs e)
        {
            // Perform the print within a try block in case a failure
            // of any type occurs.  For this sample, all errors will
            // be handled generically by simply displaying a messagebox.
            try
            {
                // Open the XML Data file.
                xmlReader = new System.Xml.XmlTextReader("..\\..\\..\\Misc\\ReportData.xml");

                // Position the pointer to the first element.
                xmlReader.Read();

                // Display a printer selection dialog.
                // Only print the document if the user clicks OK.
                if (printDialog1.ShowDialog() == DialogResult.OK)
                {
                    // This starts the actual print.  The code to output
                    // text to the selected printer resides in the PrintDocument1_PrintPage
                    // event handler.
                    printDocument1.Print();
                }

                // Close the data file.
                xmlReader.Close();
            }
            catch (Exception ex)
            {
                // If any error occurs, display a messagebox.
                MessageBox.Show("Error printing report: \r\n" + ex.Message);
            }
        }
        private void buttonPrintImage_Click(object sender, EventArgs e)
        {
            try
            {
                PrintDialog printDialog = new PrintDialog();
                printDialog.Document = this.printDocument1;
                if (printDialog.ShowDialog() != DialogResult.OK)
                {
                    throw new Exception();
                }
                /*
                PageSetupDialog pageSetupDialog = new PageSetupDialog();
                pageSetupDialog.Document = printDocument1;
                if (pageSetupDialog.ShowDialog() != DialogResult.OK)
                {
                    throw new Exception();
                }
                */
                PrintPreviewDialog printPreviewDialog = new PrintPreviewDialog();
                printPreviewDialog.Document = this.printDocument1;
                printPreviewDialog.ShowDialog();

            }
            catch (Exception)
            {
                MessageBox.Show("打印已经取消");
            }
        }
Пример #7
0
        //Stream streamToPrint, string streamType
        //2�����Print��ӡ����
        public void StartPrint()
        {
            //����ֵ��PageSettings A4\A5
            PageSettings ps = new PageSettings();
            //��ʾ���ô�ӡҳ�Ի���
            PageSetupDialog Psdl = new PageSetupDialog();
            //��ӡ������ã�ע�⣬�÷��������printpage�������档
            PrintDialog pt = new PrintDialog();
            pt.AllowCurrentPage = true;
            pt.AllowSomePages = true;
            pt.AllowPrintToFile = true;
            //       StreamToPrint = streamToPrint;//��ӡ���ֽ���
            //       StreamType = streamType; //��ӡ������
            //       printDocument1.DocumentName = Filename; //��ӡ���ļ���
            Psdl.Document = printDocument1;
            //       PrintPreview.Document = printDocument1;
            pt.Document = printDocument1;
            Psdl.PageSettings = printDocument1.DefaultPageSettings;
            try
            {
                //ҳ�����öԻ���
                if (Psdl.ShowDialog() == DialogResult.OK)
                {
                    ps = Psdl.PageSettings;
                    printDocument1.DefaultPageSettings = Psdl.PageSettings;
                }
                //ѡ���ӡ���Ի���
                if (pt.ShowDialog() == DialogResult.OK)
                {
                    printDocument1.PrinterSettings.Copies = pt.PrinterSettings.Copies;
                    //printDocument1.Print();
                    if (!checkBoxAll.Checked)
                    {
                        printDocument1.Print();
                    }
                    else
                    {
                        for (int i = 0; i < dataGridView1.RowCount; i++)
                        {
                            ShowTag(i);
                            printDocument1.Print();
                        }
                    }

                }
                ////��ӡԤ���Ի���
                //if (PrintPreview.ShowDialog() == DialogResult.OK)
                //{
                //    //���ô�ӡ
                //    printDocument1.Print();
                //}

                //PrintDocument�����Print()������PrintController����ִ��PrintPage�¼���
            }
            catch (InvalidPrinterException ex)
            {
                MessageBox.Show(ex.Message, "Simple Editor", MessageBoxButtons.OK, MessageBoxIcon.Error);
                throw;
            }
        }
Пример #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            // 프린터 설정 관련 객체
            PrinterSettings ps = new PrinterSettings();

            // 프린터 설정 관련 다이얼로그
            PrintDialog pdlg = new PrintDialog();

            // 설정 내용을 ps에 담음
            pdlg.PrinterSettings = ps;

            // PrintDialog 대화상자 출력
            pdlg.ShowDialog();

            string info = String.Format(" PrinterName = {0} \r\n PaperSizes = {1}",
                                          ps.PrinterName, ps.Copies);
            MessageBox.Show(info);

            /*
            // 프린트 설정내용을 PrintDocument 객체에 설정
            PrintDocument pd1 = new PrintDocument();
            pd1.PrinterSettings = ps;
            ...
            */
        }
Пример #9
0
        private void PrintClicked(object sender, System.EventArgs e)
        {
            if (Viewer == null)
            {
                return;
            }

            PrintDocument pd = new PrintDocument();
            pd.DocumentName = Viewer.SourceFile.LocalPath;
            pd.PrinterSettings.FromPage = 1;
            pd.PrinterSettings.ToPage = Viewer.PageCount;
            pd.PrinterSettings.MaximumPage = Viewer.PageCount;
            pd.PrinterSettings.MinimumPage = 1;
            pd.DefaultPageSettings.Landscape = Viewer.PageWidth > Viewer.PageHeight ? true : false;
            using (PrintDialog dlg = new PrintDialog())
            {
                dlg.Document = pd;
                dlg.AllowSelection = true;
                dlg.AllowSomePages = true;
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    Viewer.Print(pd);
                }
            }

        }
Пример #10
0
        public bool A4PrintSelectPrint(string printContent, int printContentLineCount)
        {
            //PrintDocument doc = new TextDocument(printContent, printContentLineCount);
            PrintDocument doc = new TextDocument(printContent);//@Salim

            doc.PrintPage += this.printDocument1_PrintPage;

            PrintDialog printDialog1 = new PrintDialog();

            // pageSetupDialog1 = new PageSetupDialog();

            if (printDialog1.ShowDialog() == DialogResult.OK)
            {
                // printDialog1.ShowDialog();

                if (printDialog1.PrinterSettings.PrinterName != null)
                {
                    if (printDialog1.PrinterSettings.PrinterName != null)
                    {
                        doc.DefaultPageSettings.PrinterSettings.PrinterName = printDialog1.PrinterSettings.PrinterName;
                        // doc.DefaultPageSettings.PrinterSettings.PrinterName = printDialog1.PrinterSettings.PaperSizes ;
                    }

                    doc.DefaultPageSettings.Landscape = true;
                    PrintDialog dlgSettings = new PrintDialog();
                    dlgSettings.Document = doc;

                    //if (dlgSettings.ShowDialog() == DialogResult.OK)
                    //{
                    doc.Print();
                }
            }
            return true;
        }
Пример #11
0
 public void PrintDoc()
 {
     System.Windows.Forms.PrintDialog dialog = new System.Windows.Forms.PrintDialog();
     if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         pagecontrol = new PageControl(settings[0]);
         if (pagecontrol.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             if (dialog.PrinterSettings.PrintToFile == false)
             {
                 control.PrintDocument(dialog.PrinterSettings, text);
                 File.AppendAllText(Environment.CurrentDirectory + "\\Output", pagecontrol.output);
                 this.Close();
             }
         }
         else
         {
             System.Windows.Forms.MessageBox.Show("Printing was canceled");
         }
     }
     else
     {
         System.Windows.Forms.MessageBox.Show("Printing was canceled");
     }
 }
 private void btPrint_Click(object sender, EventArgs e)
 {
     rowIndex           = 0;
     pageIndex          = 1;
     prnDialog.Document = prnDocument;
     prnDialog.ShowDialog();
 }
Пример #13
0
 public override void Run()
 {
     IWorkbenchWindow activeWorkbenchWindow = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
     if (activeWorkbenchWindow != null)
     {
         if (activeWorkbenchWindow.ViewContent is IPrintable)
         {
             PrintDocument printDocument = ((IPrintable) activeWorkbenchWindow.ViewContent).PrintDocument;
             if (printDocument != null)
             {
                 using (PrintDialog dialog = new PrintDialog())
                 {
                     dialog.Document = printDocument;
                     dialog.AllowSomePages = true;
                     if (dialog.ShowDialog(WorkbenchSingleton.MainForm) == DialogResult.OK)
                     {
                         printDocument.Print();
                     }
                 }
             }
             else
             {
                 MessageService.ShowError("${res:SkyMap.Net.Commands.Print.CreatePrintDocumentError}");
             }
         }
         else
         {
             MessageService.ShowError("${res:SkyMap.Net.Commands.Print.CantPrintWindowContentError}");
         }
     }
 }
        /// <summary>
        /// Confirms the printer settings.
        /// </summary>
        /// <param name="dvPriced">The dv priced.</param>
        /// <param name="dvUnpriced">The dv unpriced.</param>
        /// <param name="stvPrinterName">Name of the STV printer.</param>
        /// <param name="deliveryNotePrinter">The delivery note printer.</param>
        /// <returns></returns>
        private static bool ConfirmPrinterSettings(DataTable dvPriced, DataTable dvUnpriced, out string stvPrinterName,
                                           out string deliveryNotePrinter)
        {
            // get the printer for the stv.
            PrintDialog dialog = new PrintDialog();
            stvPrinterName = deliveryNotePrinter = "";
            if (dvPriced.Rows.Count > 0 && dialog.ShowDialog() == DialogResult.Cancel)
            {
                return false;
            }

            if (dvPriced.Rows.Count > 0)
            {
                stvPrinterName = dialog.PrinterSettings.PrinterName;
            }

            if (dvUnpriced.Rows.Count > 0)
            {
                if (dvPriced.Rows.Count > 0 &&
                    XtraMessageBox.Show(
                        "This transaction contains both priced items and unpriced items (delivery note). Are you sure you want to proceed?",
                        "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == System.Windows.Forms.DialogResult.No)
                {
                    return false;
                }

                if (dialog.ShowDialog() == DialogResult.Cancel)
                {
                    return false;
                }
                deliveryNotePrinter = dialog.PrinterSettings.PrinterName;
            }
            return true;
        }
Пример #15
0
        private void TmrPrint_Tick(object sender, EventArgs e)
        {
            pnlPrint.Visible = false;
            TmrPrint.Enabled = false;

            using (System.Drawing.Printing.PrintDocument printDocument = new System.Drawing.Printing.PrintDocument())
            {
                printDocument.PrintPage += printDocument_PrintPage;
                CaptureScreen();
                try
                { 
                    
                    PrintDialog dlg = new PrintDialog();
                    dlg.Document = printDocument;
                    dlg.PrinterSettings.Copies = 3;
                    if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        printDocument.PrinterSettings = dlg.PrinterSettings;
                        printDocument.Print();
                    }
                    else
                    {
                        pnlPrint.Visible = true;
                        return;
                    }
                }
                catch (Exception ex)
                { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,MessageBoxIcon.Error); }
            }
            Close();
            pnlPrint.Visible = true;
            
        }
Пример #16
0
 /// <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();
     }
 }
        private void button1_Click(object sender, EventArgs e)
        {
            PrintDialog pd = new PrintDialog();
            PrinterSettings ps = new PrinterSettings();
            pd.PrinterSettings = ps;
            DialogResult dr = pd.ShowDialog();

            if (dr == DialogResult.OK) {
                QRPrint printer = new QRPrint();
                printer.PrintMode = QRPrint.PrintModes.PsyBanknote;
                printer.NotesPerPage = (int)numVouchersPerPage.Value;
                switch (cboArtworkStyle.Text.ToLower()) {
                    case "yellow":
                    case "green":
                    case "blue":
                    case "purple":
                    case "greyscale":
                        printer.ImageFilename = "note-" + cboArtworkStyle.SelectedItem.ToString().ToLowerInvariant() + ".png";
                        break;
                }
                printer.Denomination = txtDenomination.Text;
                printer.keys = new List<KeyCollectionItem>(Items.Count);
                printer.PreferUnencryptedPrivateKeys = chkPrintUnencrypted.Checked;
                foreach (KeyCollectionItem a in Items) printer.keys.Add(a);
                printer.PrinterSettings = pd.PrinterSettings;
                printer.Print();
                PrintAttempted = true;
            }
        }
Пример #18
0
        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();

                }
            }



        }
Пример #19
0
        private void button1_Click(object sender, System.EventArgs e)
        {
            PageSettings    pgd = new PageSettings();
            PrinterSettings prs = new PrinterSettings();


            this.pageSetupDialog1.PageSettings    = pgd;
            this.pageSetupDialog1.PrinterSettings = prs;

            printDialog1.PrinterSettings = prs;
            printDialog1.AllowSelection  = false;
            printDialog1.AllowSomePages  = false;
            printDialog1.ShowHelp        = false;

            prs.PrinterName = prs.PrinterName;
            if (printDialog1.ShowDialog() == DialogResult.OK)
            {
                rpt.PrintOptions.PrinterName = prs.PrinterName;
                //				rpt.SaveAs(ReportSourceFileName+"2" ,ReportFileFormat.VSNetFileFormat);
            }


            //			if ( this.pageSetupDialog1.ShowDialog() == DialogResult.OK)
            {
            }

            //	printDialog1.PrinterSettings = new
        }
Пример #20
0
 public override void Print(bool ShowDialog)
 {
     printDoc = new PrintDocument();
         printDoc.PrintPage += new PrintPageEventHandler(printDoc_PrintPage);
         pd = new PrintDialog();
         pd.Document = printDoc;
         pd.AllowSomePages = true;
         if ((!ShowDialog) || (pd.ShowDialog() == DialogResult.OK))
         {
             printDoc.DocumentName = "debuglog-" + DateTime.Now.Date.ToShortDateString() + ".txt";
             strPrintText = RawTrafficText.Text.Length > 0 ? RawTrafficText.Text : " ";
             switch (pd.PrinterSettings.PrintRange)
             {
                 case PrintRange.AllPages:
                     startPage = 1;
                     totalPages = pd.PrinterSettings.MaximumPage;
                     break;
                 case PrintRange.SomePages:
                     startPage = pd.PrinterSettings.FromPage;
                     totalPages = pd.PrinterSettings.ToPage - startPage + 1;
                     break;
             }
             // start printing
             pageNumber = 1;
             printDoc.Print();
         }
 }
Пример #21
0
        public override void Execute()
        {
            printDocument = new PrintDocument();

              printDocument.OriginAtMargins = true;
              printDocument.BeginPrint += new PrintEventHandler(printDocument_BeginPrint);
              printDocument.PrintPage += new PrintPageEventHandler(printDocument_PrintPage);

              Dictionary<String, Object> paperSettings = Printing.getPaperSettings(grtArguments);
              printDocument.DefaultPageSettings.Landscape = (string)paperSettings["orientation"] == "landscape";

              // Sizes must be given in inch * 100 (sigh).
              int paperWidth = (int)Math.Round((double)paperSettings["width"] / 0.254);
              int paperHeight = (int)Math.Round((double)paperSettings["height"] / 0.254);
              PaperSize paperSize = new PaperSize("Doesn't matter", paperWidth, paperHeight);
              printDocument.DefaultPageSettings.PaperSize = paperSize;

              if ((bool)paperSettings["marginsSet"])
            printDocument.DefaultPageSettings.Margins =
              new Margins((int)paperSettings["marginLeft"], (int)paperSettings["marginRight"],
            (int)paperSettings["marginTop"], (int)paperSettings["marginBottom"]);

              printDialog = new System.Windows.Forms.PrintDialog();
              printDialog.Document = printDocument;
              printDialog.AllowPrintToFile = true;

              pageNumber = 0;
              pageCount = -1;

              if (printDialog.ShowDialog() == DialogResult.OK)
              {
            printDocument.Print();
              }
        }
Пример #22
0
        /// <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("未安装打印机", "提示");
            }
        }
Пример #23
0
        public bool Print(bool showPrintDialog)
        {
            if (showPrintDialog)
            {
                var pd = new PrintDialog
                {
                    Document = this._printDocument,
                    UseEXDialog = true,
                    AllowCurrentPage = true,
                    AllowSelection = true,
                    AllowSomePages = true,
                    PrinterSettings = this.PageSettings.PrinterSettings
                };

                if (pd.ShowDialog(Scintilla) == DialogResult.OK)
                {
                    this._printDocument.PrinterSettings = pd.PrinterSettings;
                    this._printDocument.Print();
                    return true;
                }

                return false;
            }

            this._printDocument.Print();
            return true;
        }
Пример #24
0
        /// <summary>
        /// A utility method to print preview and print an Aspose.Words document.
        /// </summary>
        internal static void Execute(Document document)
        {
            // This operation can take some time (for the first page) so we set the Cursor to WaitCursor.
            Cursor cursor = Cursor.Current;
            Cursor.Current = Cursors.WaitCursor;

            PrintPreviewDialog previewDlg = new PrintPreviewDialog();

            // Initialize the Print Dialog with the number of pages in the document.
            PrintDialog printDlg = new PrintDialog();
            printDlg.AllowSomePages = true;
            printDlg.PrinterSettings = new PrinterSettings();
            printDlg.PrinterSettings.MinimumPage = 1;
            printDlg.PrinterSettings.MaximumPage = document.PageCount;
            printDlg.PrinterSettings.FromPage = 1;
            printDlg.PrinterSettings.ToPage = document.PageCount;

            // Restore cursor.
            Cursor.Current = cursor;

            // Interesting, but PrintDialog will not show and will always return cancel
            // if you run this application in 64-bit mode.
            if (!printDlg.ShowDialog().Equals(DialogResult.OK))
                return;

            // Create the Aspose.Words' implementation of the .NET print document
            // and pass the printer settings from the dialog to the print document.
            AsposeWordsPrintDocument awPrintDoc = new AsposeWordsPrintDocument(document);
            awPrintDoc.PrinterSettings = printDlg.PrinterSettings;

            // Pass the Aspose.Words' print document to the .NET Print Preview dialog.
            previewDlg.Document = awPrintDoc;

            previewDlg.ShowDialog();
        }
Пример #25
0
        private void _printButton_Click(object sender, EventArgs e)
        {
            using (var form = new PrintDialog())
            using (var document = _document.CreatePrintDocument())
            {
                form.AllowSomePages = true;
                form.Document = document;
                form.UseEXDialog = true;
                form.Document.PrinterSettings.FromPage = 1;
                form.Document.PrinterSettings.ToPage = _document.PageCount;

                if (form.ShowDialog(FindForm()) == DialogResult.OK)
                {
                    try
                    {
                        if (form.Document.PrinterSettings.FromPage <= _document.PageCount)
                            form.Document.Print();
                    }
                    catch
                    {
                        // Ignore exceptions; the printer dialog should take care of this.
                    }
                }
            }
        }
Пример #26
0
        private void btstampa_Click(object sender, EventArgs e)
        {
            string imageFilePath = Globalne.pathfolder + "\\priznanica.bmp";
            Bitmap bitmap = (Bitmap)Image.FromFile(imageFilePath);//load the image file

            using (Graphics graphics = Graphics.FromImage(bitmap))
            {
                using (Font f = new Font("Times New Roman", 12))
                {
                    Point loc = new Point(480, 262);

                    Size s1 = new Size(134, 31);
                    Rectangle rec = new Rectangle(loc, s1);
                    graphics.DrawString(DateTime.Today.ToString().Substring(0, DateTime.Today.ToString().Length - 12), f, Brushes.Black, rec);
                    rec.X = 485;
                    rec.Y = 303;
                    graphics.DrawString(ukupno.ToString(), f, Brushes.Black, rec);

                }
            }

            bitmap.Save(Globalne.pathfolder + "\\priznanicaP.bmp");

                PrintDialog printDialog = new PrintDialog();
                printDialog.Document = printDocument1;
                printDialog.UseEXDialog = true;
                if (DialogResult.OK == printDialog.ShowDialog())
                {
                    printDocument1.DocumentName = "Račun";
                    printDocument1.Print();
                }
        }
Пример #27
0
 internal static bool showPrintDialog(
     PrintDialog printDialog,
     ref string deviceName,
     ref string driverName,
     ref string port,
     ref csReportPaperType paperSize,
     ref int orientation,
     ref int fromPage,
     ref int toPage,
     ref int copies,
     ref int paperBin)
 {
     printDialog.AllowSomePages = true;
     var settings = printDialog.PrinterSettings;
     settings.PrinterName = deviceName;
     settings.FromPage = fromPage;
     settings.ToPage = toPage;
     settings.Copies = (short)copies;
     if (printDialog.ShowDialog() == DialogResult.OK)
     {
         deviceName = settings.PrinterName;
         fromPage = settings.FromPage;
         toPage = settings.ToPage;
         copies = settings.Copies;
         return true;
     }
     else
     {
         return false;
     }
 }
Пример #28
0
 //파일 > 인쇄
 private void menuFilePrint_Click(object sender, System.EventArgs e)
 {
     if (printDialog1.ShowDialog() == DialogResult.OK) //인쇄하기를 선택할 경우
     {
         printDocument1.Print();                       //printDocument1을 프린트 시작
     }
 }
Пример #29
0
		public bool Print(bool showPrintDialog)
		{
			if (showPrintDialog)
			{
				PrintDialog pd = new PrintDialog();
				pd.Document = _printDocument;
				pd.UseEXDialog = true;
				pd.AllowCurrentPage = true;
				pd.AllowSelection = true;
				pd.AllowSomePages = true;
				pd.PrinterSettings = PageSettings.PrinterSettings;

				if (pd.ShowDialog(Scintilla) == DialogResult.OK)
				{
					_printDocument.PrinterSettings = pd.PrinterSettings;
					_printDocument.Print();
					return true;
				}

				return false;
			}

			_printDocument.Print();
			return true;
		}
Пример #30
0
        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();
                    }
                }
            }
        }
Пример #31
0
 private void btnin_Click(object sender, EventArgs e)
 {
     if(issave == false)
     {
         if(MessageBox.Show("Bạn phải lưu trước khi in, lưu ngay?", "Thông báo", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             btnluu.PerformClick();
             System.Drawing.Printing.PrintDocument myPrintDocument1 = new System.Drawing.Printing.PrintDocument();
             PrintDialog myPrinDialog1 = new PrintDialog();
             myPrintDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(myPrintDocument2_PrintPage);
             myPrinDialog1.Document = myPrintDocument1;
             if (myPrinDialog1.ShowDialog() == DialogResult.OK)
             {
                 myPrintDocument1.Print();
                 MessageBox.Show("In phiếu đặt chỗ thành công!", "Thông báo");
             }
         }
         else
         {
             System.Drawing.Printing.PrintDocument myPrintDocument1 = new System.Drawing.Printing.PrintDocument();
             PrintDialog myPrinDialog1 = new PrintDialog();
             myPrintDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(myPrintDocument2_PrintPage);
             myPrinDialog1.Document = myPrintDocument1;
             if (myPrinDialog1.ShowDialog() == DialogResult.OK)
             {
                 myPrintDocument1.Print();
                 MessageBox.Show("In phiếu đặt chỗ thành công!", "Thông báo");
             }
         }
     }
 }
Пример #32
0
 // Print Event
 private void miPrint_Click(object sender, System.EventArgs e)
 {
     if (printDialog1.ShowDialog() == DialogResult.OK)
     {
         printDocument1.Print();
     }
 }
        public void DoPrint() {
            PrintDialog printDialog = new PrintDialog();

            docToPrint.DocumentName = this.documentName;
            printDialog.AllowSomePages = true;

            printDialog.ShowHelp = true;

            printDialog.Document = docToPrint;

            DialogResult result = printDialog.ShowDialog();

            docToPrint.PrintPage += new PrintPageEventHandler(document_PrintPage);

            pages = this.printPageList.Count;
            currentPage = 0;
            if (this.printPageList.Count <= 0)
                return;

            if (result == DialogResult.OK) {
                try {
                    docToPrint.Print();
                } catch (Exception e) {
                    MessageBox.Show("Fehler beim Drucken: " + e.ToString());
                }
            }
            
        }
Пример #34
0
        /// <summary>
        /// 打印
        /// <param name="tabletitle">表头</param>
        /// <param name="table">打印内容</param>
        /// <param name="tf">设置打印横向还是纵向</param>
        /// <param name="title">打印文件的标题</param>
        /// <param name="add">附加打印内容1</param>
        /// <param name="add1">附加打印内容2</param>
        /// <param name="add2">附加打印内容3</param>
        ///  </summary>
        public static void Print(List <string> tabletitle, List <List <string> > table, bool tf, string title, string add,
                                 string add1, string add2)
        {
            try
            {
                System.Windows.Forms.PrintDialog pd = new System.Windows.Forms.PrintDialog();
                pd.AllowSomePages = true;


                var doc = CreatePrintDocument(tabletitle, table, tf, title, add, add1, add2);
                if (doc == null)
                {
                    var information = WlstMessageBox.Show
                                          ("打印提示", "打印超过10张,请重新筛选数据后打印!", WlstMessageBoxType.Ok);
                    return;
                }
                pd.Document = doc;
                if (pd.ShowDialog() == DialogResult.OK)
                {
                    doc.Print();
                    //CreatePrintDocument(tabletitle, table, tf, title, add, add1, add2).Print();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("打印错误,请检查打印设置!");
            }
        }
        private void btnPrint_Click(object sender, EventArgs e)
        {
            if(_options == null || _options.ReportText == null)
            {
                //no report
                return;
            }

            using (PrintDialog dialog = new PrintDialog())
            {
                using (System.Drawing.Printing.PrintDocument doc = new System.Drawing.Printing.PrintDocument())
                {
                    dialog.AllowSomePages = true;
                    dialog.ShowHelp = true;
                    dialog.Document = doc;

                    doc.PrintPage += doc_PrintPage;

                    if (dialog.ShowDialog() == DialogResult.OK)
                    {
                        MemoryStream stream = new MemoryStream();
                        StreamWriter writer = new StreamWriter(stream);
                        writer.Write(_options.ReportText.ToString());

                        /*
                        foreach (string line in _options.ReportText.ToString().
                            Split( new string[] {Environment.NewLine},
                                StringSplitOptions.None))
                        {
                            if (line.Length <= 40)
                                writer.WriteLine(line);
                            else
                            {
                                int remaining = line.Length;
                                for (int start = 0; start < line.Length; start += 40)
                                {
                                    if (remaining > 40)
                                        writer.WriteLine(line.Substring(start, 40));
                                    else
                                        writer.WriteLine(line.Substring(start, remaining));

                                    remaining -= 40;
                                }
                            }
                        }
                        */

                        writer.Flush();
                        stream.Position = 0;

                        streamToPrint = new StreamReader(stream);

                        doc.Print();
                    }

                    doc.PrintPage -= doc_PrintPage;
                }
            }
        }
Пример #36
0
 private void button2_Click(object sender, EventArgs e)
 {
     PrintDialog dialogo = new PrintDialog();
     printDocument1.DocumentName = "Knoodou_Relatorio_" + DateTime.Now.ToString().Replace(' ', '_');
     dialogo.Document = printDocument1;
     if (dialogo.ShowDialog() == DialogResult.OK)
         printDocument1.Print();
 }
Пример #37
0
    // ------------------------------------------------------------------
    /// <summary>
    /// Displays a PrintDialog and prints the diagram if the user elects
    /// to continue.
    /// </summary>
    // ------------------------------------------------------------------
    void Print() {
      PrintDialog dialog = new PrintDialog();
      dialog.Document = this.myDocument;

      if (dialog.ShowDialog() == DialogResult.OK) {
        this.myDocument.Print();
      }
    }
Пример #38
0
        public bool ShowPrintDialog(PrintDocument document)
        {
            var dialog = new WF.PrintDialog();

            dialog.Document    = document;
            dialog.UseEXDialog = true;
            return(dialog.ShowDialog() == WF.DialogResult.OK);
        }
Пример #39
0
		///<summary>Called from many places in the program.  Every single time we print, this function is used to figure out which printer to use.
		///It also handles displaying the dialog if necessary.  Tests to see if the selected printer is valid, and if not, then it gives user the 
		///option to print to an available printer.  PatNum and AuditDescription used to make audit log entry.  PatNum can be 0.  Audit Log Text will 
		///show AuditDescription exactly.</summary>
		public static bool SetPrinter(PrintDocument pd,PrintSituation sit,long patNum,string auditDescription){
			PrinterSettings pSet=pd.PrinterSettings;
			//pSet will always be new when this function is called
			//0.5. Get the name of the Windows default printer.
			//This method only works when the pSet is still new.
			//string winDefault=pSet.PrinterName;
			//1. If a default printer is set in OD,
			//and it is in the list of installed printers, use it.
			bool doPrompt=false;
			Printer printerForSit=Printers.GetForSit(PrintSituation.Default);//warning: this changes
			string printerName="";
			if(printerForSit!=null){
				printerName=printerForSit.PrinterName;
				doPrompt=printerForSit.DisplayPrompt;
				if(Printers.PrinterIsInstalled(printerName)) {
					pSet.PrinterName=printerName;
				}
			}
			//2. If a printer is set for this situation,
			//and it is in the list of installed printers, use it.
			if(sit!=PrintSituation.Default){
				printerForSit=Printers.GetForSit(sit);
				printerName="";
				if(printerForSit!=null){
					printerName=printerForSit.PrinterName;
					doPrompt=printerForSit.DisplayPrompt;
					if(Printers.PrinterIsInstalled(printerName)) {
						pSet.PrinterName=printerName;
					}
				}
			}
			//4. Present the dialog
			if(!doPrompt){
				//Create audit log entry for printing.  PatNum can be 0.
				SecurityLogs.MakeLogEntry(Permissions.Printing,patNum,auditDescription);
				return true;
			}
			PrintDialog dialog=new PrintDialog();
			//pSet.Collate is true here
			dialog.PrinterSettings=pSet;
			dialog.UseEXDialog=true;
			#if DEBUG
				//just use defaults
			#else
				DialogResult result=dialog.ShowDialog();
				//but dialog.PrinterSettings.Collate is false here.  I don't know what triggers the change.
				pSet.Collate=true;//force it back to true.
				if(result!=DialogResult.OK){
					return false;
				}
				//if(!dialog.PrinterSettings.IsValid){//not needed since we have already checked each name.
				//pd2.PrinterSettings=printDialog2.PrinterSettings;
				//}
			#endif
			//Create audit log entry for printing.  PatNum can be 0.
			SecurityLogs.MakeLogEntry(Permissions.Printing,patNum,auditDescription);
			return true;
		}
        private void Print(string thetext)
        {
            try //source: https://stackoverflow.com/questions/44979794/how-to-print-a-long-string-into-multiple-pages-in-c-sharp
            {
                System.Drawing.Printing.PrintDocument p = new System.Drawing.Printing.PrintDocument();

                var font  = new Font("Times New Roman", 12);
                var brush = new System.Drawing.SolidBrush(System.Drawing.Color.Black);

                // what still needs to be printed
                var remainingText = thetext;

                p.PrintPage += delegate(object sender1, System.Drawing.Printing.PrintPageEventArgs e1)
                {
                    int charsFitted, linesFilled;

                    // measure how many characters will fit of the remaining text

                    var realsize = e1.Graphics.MeasureString(
                        remainingText,
                        font,
                        e1.MarginBounds.Size,
                        System.Drawing.StringFormat.GenericDefault,
                        out charsFitted,      // this will return what we need
                        out linesFilled);

                    // take from the remainingText what we're going to print on this page
                    var fitsOnPage = remainingText.Substring(0, charsFitted);
                    // keep what is not printed on this page
                    remainingText = remainingText.Substring(charsFitted).Trim();

                    // print what fits on the page
                    e1.Graphics.DrawString(
                        fitsOnPage,
                        font,
                        brush,
                        e1.MarginBounds);

                    // if there is still text left, tell the PrintDocument it needs to call
                    // PrintPage again.
                    e1.HasMorePages = remainingText.Length > 0;
                };

                System.Windows.Forms.PrintDialog pd = new System.Windows.Forms.PrintDialog();
                pd.Document = p;
                DialogResult result = pd.ShowDialog();

                if (result == System.Windows.Forms.DialogResult.OK)
                {
                    p.Print();
                }
            }
            catch
            {
                //System.Windows.MessageBox.Show(e2.Message, "Unable to print", MessageBoxButton.OK);
            }
        }
Пример #41
0
        public void Print()
        {
            // now, show the print dialog...
            PrintDialog dialog = new PrintDialog();
            //   dialog.Document = this;

            // show the dialog...
            dialog.ShowDialog();
        }
Пример #42
0
        //打印
        public void ToPrint()
        {
            DialogResult objDlgRes = m_printDlg.ShowDialog();

            if (objDlgRes == DialogResult.Yes)
            {
                printDocument1.Print();
            }
        }
Пример #43
0
        private void btnPrint_Click(object sender, System.EventArgs e)
        {
            DialogResult userAction = printDialog.ShowDialog();

            if (userAction == DialogResult.OK)
            {
                printDocument.Print();
            }
        }
Пример #44
0
 private void button1_Click(object sender, System.EventArgs e)
 {
     printDialog1.Document = this.chartControl1.PrintDocument;
     if (printDialog1.ShowDialog() == DialogResult.OK)
     {
         //this.chartControl1.PrintColorMode = ChartPrintColorMode.Color;
         this.chartControl1.PrintDocument.Print();
     }
     this.panel1.Visible = false;
 }
Пример #45
0
        private void printClick(object sender, System.EventArgs e)
        {
            printDialog.Document = printDocument;
            DialogResult res = printDialog.ShowDialog();

            if (res == DialogResult.OK)
            {
                printDocument.Print();
            }
        }
Пример #46
0
 /// <summary>
 /// Start Printing The Report
 /// </summary>
 public void Print()
 {
     if (printDialog1.ShowDialog() == DialogResult.OK)
     {
         dataGridPrinter1         = new DataGridPrinter(myDGV, printDocument1);
         dataGridPrinter1.RHeader = ReportHeader;
         dataGridPrinter1.isRTL   = isRightToLeft;
         dataGridPrinter1.RFooter = ReportFooter;
         printDocument1.Print();
     }
 }
Пример #47
0
 private void miFilePrint_Click(object sender, System.EventArgs e)
 {
     if (textBoxEdit.SelectedText != "")
     {
         dlgPrint.AllowSelection = true;
     }
     if (dlgPrint.ShowDialog() == DialogResult.OK)
     {
         printDocument.Print();
     }
 }
Пример #48
0
        //to save the screenshot
        private void OK_Click(object sender, System.EventArgs e)
        {
            if (CheckBoxClipboard.Checked)
            {
                System.Windows.Forms.Clipboard.SetImage(oResultBitmap);
            }

            if (CheckBoxFile.Checked)
            {
                try
                {
                    //pop out the dialog to specify the file name.
                    System.Windows.Forms.SaveFileDialog ofileDlg = new System.Windows.Forms.SaveFileDialog();
                    ofileDlg.Filter = "JPEG (*.jpg)|*.jpg|PNG (*.png)|*.png|Bitmap (*.bmp)|*.bmp|" + "GIF (*.gif)|*.gif|TIFF (*.tif)|*.tif|All files (*.*)|*.*";

                    //save
                    if (ofileDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        oResultBitmap.Save(ofileDlg.FileName, GetFormatForFile(ofileDlg.FileName));
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Image creation failed:" + "\r" + ex.ToString());
                }
            }

            if (CheckBoxPrinter.Checked)
            {
                try
                {
                    PrintDocument pdoc = new PrintDocument();
                    pdoc.PrintPage += pdoc_PrintPage;

                    System.Windows.Forms.PrintDialog pdlg = new System.Windows.Forms.PrintDialog();
                    pdlg.Document = pdoc;

                    //known issue of MS: Print dialog does not show on 64bits OS.
                    //http://social.msdn.microsoft.com/Forums/en-US/netfx64bit/thread/a707d202-1a8b-43b1-9fff-08aa7ceb200a
                    //*******
                    pdlg.UseEXDialog = true;
                    //******

                    if (pdlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                    {
                        pdoc.Print();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
        }
Пример #49
0
 private void prntPrintMenu_Click(object sender, System.EventArgs e)
 {
     pagenum = 0;
     if (activeReport != null)
     {
         if (printDialog1.ShowDialog(this) == DialogResult.OK)
         {
             printRep = ReportBuilder.ReloadRep(activeReport, true);
             printDocument1.Print();
         }
     }
 }
Пример #50
0
 public void InitPrintDialog()
 {
     //page setup
     this.printPreview.Document         = this.printDoc;
     this.printPreview.AllowCurrentPage = true;
     this.printPreview.AllowSomePages   = true;
     this.printPreview.UseEXDialog      = true;
     if (printPreview.ShowDialog() == DialogResult.OK)
     {
         printDoc.Print();
     }
 }
Пример #51
0
        private void printButton_Click(object sender, EventArgs e)
        {
            var printDialog = new swf.PrintDialog();

            printDialog.Document = Control.Document;

            if (printDialog.ShowDialog() == swf.DialogResult.OK)
            {
                Control.Document.PrinterSettings = printDialog.PrinterSettings;
                Control.Document.Print();
            }
        }
Пример #52
0
        public void Print()
        {
            var printDialog = new System.Windows.Forms.PrintDialog();
            var doc         = new PrintDocument();

            printDialog.Document = doc;
            doc.PrintPage       += new PrintPageEventHandler(ProvideContent);
            if (printDialog.ShowDialog() == DialogResult.OK)
            {
                doc.Print();
            }
        }
Пример #53
0
        private void PaymentInvoice()
        {
            if (ChooseReportWindow.Window != null)
            {
                ChooseReportWindow.Window.Close();
            }
            var pivm = new PrintInvoiceViewModel();
            var printDialogWindow = new PrintPreview();

            pivm.InvoiceNumber = SelectedRacuni.Brev;
            pivm.InvoiceDate   = SelectedRacuni.Datum;
            pivm.Name          = SelectedRacuni.Kupci.Ime;
            pivm.Jmbg          = SelectedRacuni.Kupci.Jmbg;
            pivm.City          = SelectedRacuni.Kupci.Mesto;
            pivm.Address       = SelectedRacuni.Kupci.Adresa;

            foreach (var e in SelectedRacuni.RevRobas.Items)
            {
                var vm = new PrintInvoiceLineViewModel();
                vm.Roba   = e.Roba.Naziv;
                vm.Amount = e.Kolic;
                vm.Price  = e.Cena;
                vm.Date   = e.Datum;
                vm.Days   = e.Utro;
                vm.Value  = e.Cena * e.Utro;
                pivm.Items.Add(vm);
            }

            var path = ReportFactory.RunReport(pivm, "ReversStampa", "WpfApplication3.Reports.PaymentInvoiceReportA4.rdlc");

            var pdf = PdfiumViewer.PdfDocument.Load(path);

            printDialogWindow.pdfViewer1.Document = pdf;
            var printpdf = printDialogWindow.pdfViewer1.Document.CreatePrintDocument();
            var pd       = new System.Windows.Forms.PrintDialog();

            pd.Document    = printpdf;
            pd.UseEXDialog = true;
            DialogResult result = pd.ShowDialog();

            if (result == DialogResult.OK)
            {
                try
                {
                    printpdf.Print();
                }
                catch (InvalidPrinterException ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Пример #54
0
        public void PrintDocument()
        {
            Visio.Document  doc    = axDrawingControl1.Document;
            Visio.Selection select = doc.Application.ActiveWindow.Selection;

            System.Windows.Forms.PrintDialog printDialog = new System.Windows.Forms.PrintDialog();
            if (printDialog.ShowDialog() == DialogResult.OK)
            {
                var PrinterName = printDialog.PrinterSettings.PrinterName;

                doc.PrintOut(Visio.VisPrintOutRange.visPrintCurrentView, 1, -1, true, PrinterName);
            }
        }
        public void Print()
        {
            var dlg = new System.Windows.Forms.PrintDialog();

            System.Drawing.Printing.PrintDocument doc = new System.Drawing.Printing.PrintDocument();
            dlg.Document = doc;
            if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                _charsPrinted  = 0;
                doc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(doc_PrintPage);
                doc.Print();
            }
        }
Пример #56
0
        /// <summary>
        /// 二、开始打印
        /// </summary>
        private void DoPrint()
        {
            try
            {
                //printDocument.PrinterSettings可以获取或设置计算机默认打印相关属性或参数,如:printDocument.PrinterSettings.PrinterName获得默认打印机打印机名称
                //printDocument.DefaultPageSettings   //可以获取或设置打印页面参数信息、如是纸张大小,是否横向打印等

                //设置文档名
                printDocument.DocumentName = "医惠物联网定位卡";//设置完后可在打印对话框及队列中显示(默认显示document)

                ////设置纸张大小(可以不设置取,取默认设置)
                //PaperSize ps = new PaperSize("A4", 100, 70);
                //ps.RawKind = 150; //如果是自定义纸张,就要大于118,(A4值为9,详细纸张类型与值的对照请看http://msdn.microsoft.com/zh-tw/library/system.drawing.printing.papersize.rawkind(v=vs.85).aspx)
                //printDocument.DefaultPageSettings.PaperSize = ps;

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

                //跳出打印对话框,提供打印参数可视化设置,如选择哪个打印机打印此文档等
                System.Windows.Forms.PrintDialog pd = new System.Windows.Forms.PrintDialog();
                pd.Document = printDocument;
                if (DialogResult.OK == pd.ShowDialog()) //如果确认,将会覆盖所有的打印参数设置
                {
                    //页面设置对话框(可以不使用,其实PrintDialog对话框已提供页面设置)
                    PageSetupDialog psd = new PageSetupDialog();
                    psd.Document = printDocument;
                    if (DialogResult.OK == psd.ShowDialog())
                    {
                        //打印预览
                        PrintPreviewDialog ppd = new PrintPreviewDialog();
                        ppd.Document    = printDocument;
                        ppd.WindowState = FormWindowState.Maximized;
                        ppd.PrintPreviewControl.Zoom = 1.0;
                        if (DialogResult.OK == ppd.ShowDialog())
                        {
                            printDocument.Print();          //打印
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message, "打印出错!", MessageBoxButtons.OK, MessageBoxIcon.Warning,
                                                     MessageBoxDefaultButton.Button1);
                Log.CreateLog(ex);
            }
        }
Пример #57
0
        private void btnPrintSetting_Click(object sender, EventArgs e)
        {
            PrintDialog printDialog1 = new System.Windows.Forms.PrintDialog();

            if (printDialog1.ShowDialog() == DialogResult.OK)//弹出选择印表机的窗体
            {
                string strBagPrint = printDialog1.PrinterSettings.PrinterName.ToString();

                Configuration cfa = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                cfa.AppSettings.Settings["bagPrint"].Value = strBagPrint;
                cfa.Save();
                //UpdateConfig("bagPrint", strBagPrint);
            }
        }
Пример #58
0
        //Perform file and print actions
        private void DoFileAction(object sender)
        {
            frmDiagram active = (frmDiagram)this.ActiveMdiChild;

            //Open
            if (sender == mnuFileOpen || sender == btnOpen)
            {
                active.Open("");
            }

            //Save
            if (sender == mnuFileSave || sender == btnSave)
            {
                active.Save(active.Path);
            }

            //Save as
            if (sender == mnuFileSaveAs)
            {
                active.Save("");
            }

            //Print preview
            if (sender == mnuFilePrintPreview)
            {
                Crainiate.Diagramming.Printing.PrintDocument print = new Crainiate.Diagramming.Printing.PrintDocument(active.Model);
                print.PrintPreview(new Point(100, 100), new Size(800, 600));
                return;
            }

            //Print with settings
            if (sender == mnuFilePrint || sender == btnPrint)
            {
                Crainiate.Diagramming.Printing.PrintDocument print         = new Crainiate.Diagramming.Printing.PrintDocument(active.Model);
                System.Windows.Forms.PrintDialog             printDialogue = new System.Windows.Forms.PrintDialog();
                printDialogue.Document = print;

                if (printDialogue.ShowDialog() == DialogResult.OK)
                {
                    print.Print();
                }
                return;
            }

            if (sender == mnuFileExit)
            {
                this.Close();
            }
        }
Пример #59
-2
        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();
                }
            }
        }
Пример #60
-2
        static void Main(string[] args)
        {
            PdfDocument doc = new PdfDocument();
            doc.LoadFromFile("sample.pdf");

            //Use the default printer to print all the pages
            //doc.PrintDocument.Print();

            //Set the printer and select the pages you want to print

            PrintDialog dialogPrint = new PrintDialog();
            dialogPrint.AllowPrintToFile = true;
            dialogPrint.AllowSomePages = true;
            dialogPrint.PrinterSettings.MinimumPage = 1;
            dialogPrint.PrinterSettings.MaximumPage = doc.Pages.Count;
            dialogPrint.PrinterSettings.FromPage = 1;
            dialogPrint.PrinterSettings.ToPage = doc.Pages.Count;

            if (dialogPrint.ShowDialog() == DialogResult.OK)
            {
                //Set the pagenumber which you choose as the start page to print
                doc.PrintFromPage = dialogPrint.PrinterSettings.FromPage;
                //Set the pagenumber which you choose as the final page to print
                doc.PrintToPage = dialogPrint.PrinterSettings.ToPage;
                //Set the name of the printer which is to print the PDF
                doc.PrinterName = dialogPrint.PrinterSettings.PrinterName;

                PrintDocument printDoc = doc.PrintDocument;
                dialogPrint.Document = printDoc;
                printDoc.Print();
            }
        }