Hi,
Document prints immediately when I click print button, I want to show the print dialog first. How to do that?
Thanks,
Jeisma
private void btnPrint_Click(object sender, EventArgs e)
{
if (this.pdfDocumentViewer1.PageCount > 0)
{
//Set the print dialog
PrintDialog dialogPrint = new PrintDialog();
dialogPrint.AllowPrintToFile = true;
dialogPrint.AllowSomePages = true;
dialogPrint.PrinterSettings.MinimumPage = 1;
dialogPrint.PrinterSettings.MaximumPage = this.pdfDocumentViewer1.PageCount;
dialogPrint.PrinterSettings.FromPage = 1;
dialogPrint.PrinterSettings.ToPage = this.pdfDocumentViewer1.PageCount;
dialogPrint.PrinterSettings.PrinterName = "Microsoft XPS Document Writer";
if (dialogPrint.ShowDialog() == DialogResult.OK)
{
//Set the pagenumber which you choose to print
this.pdfDocumentViewer1.PrintSettings.SelectPageRange(dialogPrint.PrinterSettings.FromPage, dialogPrint.PrinterSettings.ToPage);
this.pdfDocumentViewer1.PrintSettings.PrinterName = dialogPrint.PrinterSettings.PrinterName;
this.pdfDocumentViewer1.PrintDoc();
}
}
}