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 PrintDocument of the System.Drawing.Printing namespace, it is necessary to specify page settings and page orientation programmatically. In TX Text Control .NET for Windows Forms, the ratio of the page width to the page height indicates whether a document is of landscape or portrait orientation. However,…

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 PrintDocument of the System.Drawing.Printing namespace, it is necessary to specify page settings and page orientation programmatically.
In TX Text Control .NET for Windows Forms, 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 for Windows Forms, 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);
}
Related Posts
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…
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…
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…
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,…
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…