private void _printButton_Click(object sender, EventArgs e) { using (var form = new PrintDialog()) using (var document = _document.CreatePrintDocument(DefaultPrintMode)) { 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. } } } }
private void Print_Click(object sender, EventArgs e) { PrintDocument pd = new PrintDocument(); var dlg = new PrintDialog(); dlg.AllowCurrentPage = true; dlg.AllowSomePages = true; dlg.UseEXDialog = true; dlg.Document = pd; if (dlg.ShowDialog() == DialogResult.OK) { pdfDocument.CreatePrintDocument(); } }