Exemplo n.º 1
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            if (!PdfOK())
            {
                return;
            }
            try
            {
                string fileName = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".ps";

                if (printDialog1.ShowDialog() == DialogResult.OK)
                {
                    using (StatusBusy sb = new StatusBusy(Resources.UIStrings.StatusPrinting))
                    {
                        if (printDialog1.PrinterSettings.PrintToFile)
                        {
                            saveFileDialog1.Filter = "PostScript File (*.ps)|*.ps";
                            if (this.saveFileDialog1.ShowDialog() == DialogResult.OK)
                            {
                                _pdfDoc.PrintToFile(saveFileDialog1.FileName, 1, _pdfDoc.PageCount);
                            }
                        }
                        else
                        {
                            _pdfDoc.PrintToFile(fileName, 1, _pdfDoc.PageCount);
                            RawPrinterHelper.SendFileToPrinter(printDialog1.PrinterSettings.PrinterName, fileName);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }