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.