I have a simple printing solution set up and normal printing works fine(tested it a couple of times), however when I use the PrintDialog to specify a custom page range, it is as if the range is ingored. When I debug I inspect the printDocument object and confirm that the range values are correct but the end product that the printer produces does not much the values I gave it.
Here is my code :
printDialog.Document = printdoc;
printDialog.AllowSomePages = true;
if (printDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
printdoc.PrinterSettings.FromPage = printDialog.PrinterSettings.FromPage;
printdoc.PrinterSettings.ToPage = printDialog.PrinterSettings.ToPage;
printdoc.PrinterSettings.PrintRange = printDialog.PrinterSettings.PrintRange;
printPreviewDialog.Document = printdoc;
printPreviewDialog.FindForm().WindowState = FormWindowState.Maximized;
printPreviewDialog.ShowDialog();
}
*Note - printdoc is a instance of System.Drawing.Printing.PrintDocument. I added code in the PrintDocument's PrintPage event handler to populate the page I'm printing.