Did you know that Text Control's US office is in Charlotte, NC?
Call your sales representative at: +1 704-544-7445.
 

TX Text Control Source Code Library

Printing to different paper trays

Printing to different paper trays is daily business. The first page of a business letter is often printed on pre-printed letterhead. Or the envelope should be printed in the same print job, but using another paper source.

TX Text Control .NET for Windows Forms has been built for the .NET Framework and therefore it is very flexible, and can be used with the standards of .NET. This sample implements a very nice dialog box that can be used to specify the different paper sources for specific pages.

The first combo box allows you to select the required printer. In the Page settings, you can select a specific page in combination with an available paper source. By clicking Add settings, the selected combination is added and displayed in the grid view.

Apart from the code to select the printer or to get the available paper sources, the printing code is very simple. First, a new PrintDocument is created in order to attach a QueryPageSettings event. Then TX Text Control's Print method is called:

PrintDocument myDoc = new PrintDocument(); myDoc.QueryPageSettings += new QueryPageSettingsEventHandler(myDoc_QueryPageSettings); _tx.Print(myDoc);

This event is fired every time before a new page is printed and can be used to change the printer and page settings. We are using the event to change the paper sources according to our list of page settings.

void myDoc_QueryPageSettings(object sender, QueryPageSettingsEventArgs e) { pageCount++; foreach (PageSetting testSetting in MyPageSettings) { if (testSetting.PageNumber == pageCount) { e.PageSettings.PaperSource = testSetting.PaperSource; break; } else e.PageSettings.PaperSource = myDoc.PrinterSettings.PaperSources[0]; } }

Note that at least TX Text Control .NET for Windows Forms 14.0 trial version and Visual Studio .NET 2005 are required to run this sample.

 
 
Call us: +1 704-544-7445 (United States)
 
 

Products

Support

Downloads

Corporate

Buy Now

About Text Control

Founded in 1991, Text Control is an award-winning Visual Studio Industry Partner and leading vendor of word processing and reporting components for Microsoft development technologies. The products help thousands of developers add comprehensive word processing functionality to their applications. Text Control is 100% self-owned and independent of all investor decisions. Customers benefit from these years of experience, large user-base, and at the same time, appreciate developing with a mature, reliable product.

TX Text Control logo

The TX Text Control logo is a registered trademark in the United States, Europe and other countries.