PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 12:22 pm

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Tue Jan 27, 2015 2:00 am 
Offline

Joined: Tue Jan 27, 2015 1:30 am
Posts: 1
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:


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 44 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group