Products Technologies Demo Docs Blog Support Company

Printing into a PrintPreview Control II

This follow-up corrects an oversight in the original PrintPreview sample for TX Text Control. After initializing the PrintPreviewDialog with a custom PrintController, the Activated event handler must replace it with a StandardPrintController so the dialog print button works.

Printing into a PrintPreview Control II

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();

Stay in the loop!

Subscribe to the newsletter to receive the latest updates.

Related Posts

.NETPrintingSample

Batch Printing: How to Print Documents in One Print Job

Batch printing multiple documents as a single print job using TX Text Control relies on a .NET PrintDocument with PrintPage and QueryPageSettings events. Each page is rendered individually via the…


.NETPrintingSample

New Sample: Printing to Different Paper Trays

A new TX Text Control .NET for Windows Forms sample demonstrates printing specific document pages to different paper sources on the current printer. The project includes a configurable dialog box…


PrintingSample

New Sample: Printing Watermarks

TX Text Control 14.0 adds support for printing watermarks by trapping the OnPrintPage event of the PrintDocument class and drawing graphics onto each page. A sample project demonstrates how to…


.NETPrintingSample

Printing into a PrintPreview Control

TX Text Control .NET for Windows Forms provides a built-in PrintPreview method, but the standard .NET PrintPreviewDialog offers broader customization options. This sample shows how to use the…


.NETPrintingSample

Printing Without the Status Dialog

The default .NET print controller displays a progress status dialog during printing operations. Replacing PrintControllerWithStatusDialog with StandardPrintController from System.Drawing.Printing…

Share on this blog post on: