public static DialogResult ShowPrintPreview(PdfDocument pdf, PrintSize printSize)
        {
            using (var previewDialog = new PrintPreviewDialog())
            {
                using (var printDocument = new PdfPrintDocument(pdf, printSize))
                {
                    previewDialog.Document = printDocument.PrintDocument;

                    // By default the print button sends the preview to the default printer
                    // The following method replaces the default button with the custom button.
                    // The custom button opens print dialog.
                    setupPrintButton(previewDialog, pdf, printSize);

                    // Remove the following line if you do not want preview maximized
                    previewDialog.WindowState = FormWindowState.Maximized;

                    return(previewDialog.ShowDialog());
                }
            }
        }
        public static DialogResult ShowPrintDialog(PdfDocument pdf, PrintSize printSize)
        {
            using (var printDialog = new PrintDialog())
            {
                printDialog.AllowSomePages   = true;
                printDialog.AllowCurrentPage = true;
                printDialog.AllowSelection   = true;

                printDialog.PrinterSettings.MinimumPage = 1;
                printDialog.PrinterSettings.MaximumPage = pdf.PageCount;
                printDialog.PrinterSettings.FromPage    = printDialog.PrinterSettings.MinimumPage;
                printDialog.PrinterSettings.ToPage      = printDialog.PrinterSettings.MaximumPage;

                var result = printDialog.ShowDialog();
                if (result == DialogResult.OK)
                {
                    using (var printDocument = new PdfPrintDocument(pdf, printSize))
                        printDocument.Print(printDialog.PrinterSettings);
                }

                return(result);
            }
        }