If the user prints a page range, whose last page is past the end of the document, an unhanded exception is thrown because the setting of MigraDocPrintDocument.pageCount in
Code:
protected override void OnBeginPrint(PrintEventArgs e)
ignores the actual number of pages. The following is a proposed fix.
Code:
Index: MigraDocPrintDocument.cs
===================================================================
--- MigraDocPrintDocument.cs (revision 200)
+++ MigraDocPrintDocument.cs (working copy)
@@ -108,7 +108,10 @@
case PrintRange.SomePages:
this.pageNumber = PrinterSettings.FromPage;
- this.pageCount = PrinterSettings.ToPage - PrinterSettings.FromPage + 1;
+ var toPage = this.PrinterSettings.ToPage > this.renderer.FormattedDocument.PageCount
+ ? this.renderer.FormattedDocument.PageCount
+ : this.PrinterSettings.ToPage;
+ this.pageCount = toPage - PrinterSettings.FromPage + 1;
break;
case PrintRange.Selection: