Products Technologies Demo Docs Blog Support Company

Printing into a PrintDocument

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…

Printing into a PrintDocument

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.

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

A typical requirement when printing loads of documents is managing the print jobs. A group of separate documents might be subsumed in a single print job. We just published a new sample in our…


.NETPrintingSample

New Sample: Printing to Different Paper Trays

We just released a new sample for TX Text Control .NET for Windows Forms. This sample shows how to print specific pages of a document to different paper sources of the current printer. The sample…


.NETPrintingSample

Printing into a PrintPreview Control

TX Text Control .NET for Windows Forms implements a print preview dialog that can be easily opened using the PrintPreview method. Sometimes, it is necessary to customize the print preview dialog…


.NETPrintingSample

Printing Without the Status Dialog

The default print controller of .NET displays a status dialog that shows the status of the printing process like this: 'Page 5 of document' If you want to print without such a print status dialog,…


.NETPrintingSample

Landscape Printing with a PrintDocument

In one of the Print method's overload, TX Text Control .NET for Windows Forms allows a PrintDocument to be passed. The PrintDocument class is used to send output to a printer. In order to use…