In this sample, I explained how to print into a .NET Framework PrintPreviewDialog control.
https://github.com/TextControl/
A customized PrintController has been derived from the PrintController class. But I forgot to tell you to reset the PrintController after initializing the dialog. This is important, because the dialog provides a button to print the content to the specified printer directly. If the PrintController is the inherited one, its content will not be printed.
Therefore, we have to pass a new PrintController, after the dialog has been initialized. We can attach an Actived event where the dialog will be opened:
pp.Activated += new EventHandler(pp_Activated);
In the event, we will create a new PrintController:
void pp_Activated(object sender, EventArgs e) { pp.Document.PrintController = new StandardPrintController(); }
The PrintPreviewDialog must be accessible in this sample:
private PrintPreviewDialog pp = new PrintPreviewDialog();