# 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.

- **Author:** Bjoern Meyer
- **Published:** 2006-06-12
- **Modified:** 2026-03-05
- **Description:** 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.
- **1 min read** (194 words)
- **Tags:**
  - .NET
  - Printing
  - Sample
- **Web URL:** https://www.textcontrol.com/blog/2006/06/12/printing-into-a-printdocument/
- **LLMs URL:** https://www.textcontrol.com/blog/2006/06/12/printing-into-a-printdocument/llms.txt
- **LLMs-Full URL:** https://www.textcontrol.com/blog/2006/06/12/printing-into-a-printdocument/llms-full.txt

---

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.

---

## About Bjoern Meyer

As CEO, Bjoern is the visionary behind our strategic direction and business development, bridging the gap between our customers and engineering teams. His deep passion for coding and web technologies drives the creation of innovative products. If you're at a tech conference, be sure to stop by our booth - you'll most likely meet Bjoern in person. With an advanced graduate degree (Dipl. Inf.) in Computer Science, specializing in AI, from the University of Bremen, Bjoern brings significant expertise to his role. In his spare time, Bjoern enjoys running, paragliding, mountain biking, and playing the piano.

- [LinkedIn](https://www.linkedin.com/in/bjoernmeyer/)
- [X](https://x.com/txbjoern)
- [GitHub](https://github.com/bjoerntx)

---

## Related Posts

- [Batch Printing: How to Print Documents in One Print Job](https://www.textcontrol.com/blog/2009/03/20/batch-printing-how-to-print-documents-in-one-print-job/llms.txt)
- [New Sample: Printing to Different Paper Trays](https://www.textcontrol.com/blog/2008/10/08/new-sample-printing-to-different-paper-trays/llms.txt)
- [Printing into a PrintPreview Control](https://www.textcontrol.com/blog/2007/08/10/printing-into-a-printpreview-control/llms.txt)
- [Printing Without the Status Dialog](https://www.textcontrol.com/blog/2007/02/07/printing-without-the-status-dialog/llms.txt)
- [Landscape Printing with a PrintDocument](https://www.textcontrol.com/blog/2006/07/03/landscape-printing-with-a-printdocument/llms.txt)
- [Create a Table of Contents in Windows Forms using C#](https://www.textcontrol.com/blog/2023/01/23/create-toc-in-windows-forms/llms.txt)
- [Two Ways to Restart Numbered Lists in TX Text Control](https://www.textcontrol.com/blog/2021/11/03/two-ways-to-restart-numbered-lists/llms.txt)
- [Paste Special: The Easy Way to Implement](https://www.textcontrol.com/blog/2009/09/07/paste-special-the-easy-way-to-implement/llms.txt)
- [How to Remove All Section Breaks in a Document?](https://www.textcontrol.com/blog/2009/05/14/how-to-remove-all-section-breaks-in-a-document/llms.txt)
- [Removing TextFields in a Loop](https://www.textcontrol.com/blog/2009/03/12/removing-textfields-in-a-loop/llms.txt)
- [Creating a Table of Contents (TOC) Using TX Text Control](https://www.textcontrol.com/blog/2009/02/02/creating-a-table-of-contents-toc-using-tx-text-control/llms.txt)
- [Rendering TX Text Control's Content to a DataGridViewCell](https://www.textcontrol.com/blog/2009/01/20/rendering-tx-text-controls-content-to-a-datagridviewcell/llms.txt)
- [Revised Sample: Converting Text to a Table](https://www.textcontrol.com/blog/2009/01/07/revised-sample-converting-text-to-a-table/llms.txt)
- [Is the Current Input Position Currently Visible?](https://www.textcontrol.com/blog/2008/09/04/is-the-current-input-position-currently-visible/llms.txt)
- [New Sample: Implementing a 'paste Special' Dialog Box](https://www.textcontrol.com/blog/2008/07/10/new-sample-implementing-a-paste-special-dialog-box/llms.txt)
- [The ParagraphStyle and InlineStyle Constructor Unreveled](https://www.textcontrol.com/blog/2008/06/24/the-paragraphstyle-and-inlinestyle-constructor-unreveled/llms.txt)
- [Searching with C# Escape Sequences](https://www.textcontrol.com/blog/2008/05/29/searching-with-c-escape-sequences/llms.txt)
- [Removing Empty Tables](https://www.textcontrol.com/blog/2008/05/27/removing-empty-tables/llms.txt)
- [Manipulating the Selection Object](https://www.textcontrol.com/blog/2008/05/26/manipulating-the-selection-object/llms.txt)
- [Casting TextField Derivatives](https://www.textcontrol.com/blog/2008/05/23/casting-textfield-derivatives/llms.txt)
- [Resize Images to Fit into Page](https://www.textcontrol.com/blog/2008/05/08/resize-images-to-fit-into-page/llms.txt)
- [New Sample: Printing Watermarks](https://www.textcontrol.com/blog/2008/01/28/new-sample-printing-watermarks/llms.txt)
- [Printing into a PrintPreview Control II](https://www.textcontrol.com/blog/2007/11/19/printing-into-a-printpreview-control-ii/llms.txt)
- [Drag And Drop Images into TX Text Control .NET for Windows Forms](https://www.textcontrol.com/blog/2007/08/09/drag-and-drop-images-into-tx-text-control-net-for-windows-forms/llms.txt)
- [New Sample: Restarting a Numbered List](https://www.textcontrol.com/blog/2007/08/08/new-sample-restarting-a-numbered-list/llms.txt)
