Skype:TextControlSupport
Orders:877-462-4772
TX Text Control - word processing components.
« »

Landscape printing with a PrintDocument

Blogged by Björn Meyer on July 03, 2006 and tagged with Samples, .NET, Printing.

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

In order to use PrintDocument of the System.Drawing.Printing namespace, it is necessary to specify page settings and page orientation programmatically.

In TX Text Control .NET, the ratio of the page width to the page height indicates whether a document is of landscape or portrait orientation. However, this property is not passed to the PrintDocument object automatically.

The following function creates a new PrintDocument object and passes the appropriate values from the current instance of TX Text Control .NET, including page orientation, page size and page margins:

private void PrintDocument(TXTextControl.TextControl tx)
{
PrintDocument pd = new PrintDocument();

if(tx.PageSize.Width > tx.PageSize.Height)
pd.DefaultPageSettings.Landscape = true;
else
pd.DefaultPageSettings.Landscape = false;

pd.DefaultPageSettings.PaperSize = new PaperSize("new size", tx.PageSize.Width, tx.PageSize.Height);
pd.DefaultPageSettings.Margins = new Margins(tx.PageMargins.Left, tx.PageMargins.Right, tx.PageMargins.Top, tx.PageMargins.Bottom);

tx.Print(pd);
}
« Prev:Build a word processor in 2 minutes
» Next:Whitepaper: Hands On Mail Merge

top

Top 10 Bestselling Product Award 2007Top 25 Publisher Product Award 2007Top 10 Bestselling Product Award 2007 in JapanTop 25 Bestselling Product Award 2006Top 25 Bestselling Publisher Award 2006Reader's Choice Award, dot.net magazin, 3rd place