This sample project implements the class MultipagePrintDocument that inherits from System.Drawing.Printing.PrintDocument to print multiple pages of a document per sheet.

Windows Forms: Printing multiple pages per sheet

The constructor of MultipagePrintDocument accepts an instance of TXTextControl.TextControl that is used to create the page thumbnails in the printing process, the number of pages per sheet and a boolean value to specify whether the light gray border should be printed or not between the pages.

Loading...

The OnBeginPrint method is overridden to check for specified PrinterSettings:

Loading...

The overridden method OnPrintPage contains the main logic and controls the printing process. Based on the specified number of pages, the width and height of the available columns and rows per sheet are calculated and for each page, a thumbnail image is created using TX Text Control's GetImage method. The image is scaled to the width of the defined columns to create a multipage document.

Finally, the created Metafile images are rendered on the Graphics object of each page in the PrintDocument.

Loading...

The method GetThumbnailValuePair returns the required grid size based on the given number of pages per sheet:

Loading...

This code shows how to call the MultipagePrintDocument and how to open a PrintPreviewDialog with the results:

Loading...

Download the sample from GitHub and test it on your own.

GitHub

Download and Fork This Sample on GitHub

We proudly host our sample code on github.com/TextControl.

Please fork and contribute.

Requirements for This Sample

  • Visual Studio 2012 or better
  • TX Text Control .NET for Windows Forms (trial sufficient)