Print a custom document with .NET is quite simple and straightforward.
The start point to print is to create a PrintDocument object, add event handlers that fit your application needs and invoke the method Print().
The following event handlers are available for the PrintDocument object:
The BeginPrint event is raised just once and before the first page prints.
Use the event to preset print level properties.
The EndPrint event is raised just once and after the last page has printed.
Use the event to release resources, notify the user that the print has finished or any other after print needs.
The PrintPage event is raised for each page and while the PrintDocument object has pages to be printed.
This is where the magic happens. Use the event to set the content that will be printed in the current page like text, images and so on.
For each printed page you’ll have to check if more pages must be printed and set the boolean property HasMorePages from the PrintEventArgs parameter to allow the event be raised again or finish the print process.
The QueryPageSettings event is raised before each page prints.
Use the event to preset page level properties.