Printing into a PrintDocument
TX Text Control .NET for Windows Forms prints into a standard .NET PrintDocument object, giving full control over page size, margins, and printer settings. To print a single page, set PrintRange to SomePages and specify matching FromPage and ToPage values in PrinterSettings.

TX Text Control .NET for Windows Forms's Print method introduces many advantages over the Print method of the ActiveX control. It enables you to print into a PrintDocument of the System.Drawing.Printing namespace. TX Text Control .NET for Windows Forms's Print method uses the following settings of this object:
- DocumentName
- PrintController
- PrinterSettings.FromPage
- PrinterSettings.ToPage
- PrinterSettings.Copies
- PrinterSettings.Collate
- PrinterSettings.PrinterName
- PrinterSettings.PrintToFile
- PrinterSettings.PrintRange
- DefaultPageSettings.Color
If you would like to print one specific page of the document, not only FromPage and ToPage must be specified, but also the PrintRange property. The following code sample prints page 2 of TX Text Control and sets the current page size.
int m_curPage = 2;
PrintDocument myPrintDoc = new PrintDocument();
myPrintDoc.DefaultPageSettings.PaperSize = new PaperSize("default", thisTX.PageSize.Width, thisTX.PageSize.Height);
myPrintDoc.DefaultPageSettings.Margins = new Margins(thisTX.PageMargins.Left, thisTX.PageMargins.Right, _
thisTX.PageMargins.Top, thisTX.PageMargins.Bottom);
myPrintDoc.PrinterSettings.PrintRange = PrintRange.SomePages;
myPrintDoc.PrinterSettings.FromPage = m_curPage;
myPrintDoc.PrinterSettings.ToPage = m_curPage;
thisTX.Print(myPrintDoc);
As you can see, the PrintPage property must be specified with SomePages which indicates that the FromPage and ToPage is considered.
Related Posts
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…
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…
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…
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…
Landscape Printing with a PrintDocument
When printing with a PrintDocument object in TX Text Control .NET for Windows Forms, page orientation is not transferred automatically. This C# function creates a PrintDocument, compares page…
