New to Telerik UI for WinFormsStart a free 30-day trial

Defines a reusable object that sends output to a printer and manages the whole printing process, when printing from an application. Can be associated with any object that implements the IPrintable interface.

Definition

Constructors

Initializes a new instance of the RadPrintDocument class.

C#
public RadPrintDocument()

Fields

C#
public const string DatePrintedString = "[Date Printed]"
C#
public const string LogoString = "[Logo]"
C#
public const string PageNumberString = "[Page #]"
C#
public const string TimePrintedString = "[Time Printed]"
C#
public const string TotalPagesString = "[Total Pages]"
C#
public const string UserNamePrintedString = "[User Name]"

Properties

Gets or sets the IPrintable object associated with this document for printing.

C#
[Browsable(true)]
public IPrintable AssociatedObject { get; set; }
Property Value:

An object that implements IPrintable, or null if no object is associated.

Gets or sets a value indicating whether the orientation should be automatically determined based on the content.

C#
[Browsable(true)]
public bool AutoPortraitLandscape { get; set; }
Property Value:

true to automatically choose between portrait and landscape; otherwise, false.

Gets or sets the currently selected page. This page will be the first to be printed when the PrintRange is set to Current or Selection.

C#
[Browsable(false)]
public int CurrentPage { get; set; }

Gets or sets the font of the page footer.

C#
[Browsable(true)]
public Font FooterFont { get; set; }

Gets or sets the height of the footer area in hundredths of an inch.

C#
[Browsable(true)]
public int FooterHeight { get; set; }
Property Value:

An integer representing the footer height.

Gets or sets the font of the page header.

C#
[Browsable(true)]
public Font HeaderFont { get; set; }

Gets or sets the height of the header area.

C#
[Browsable(true)]
public int HeaderHeight { get; set; }

Indicates whether the printing process is running.

C#
[Browsable(false)]
public bool IsPrinting { get; }

Gets or sets a value indicating whether the document should be printed in landscape orientation.

C#
[Browsable(true)]
public bool Landscape { get; set; }
Property Value:

true to print in landscape orientation; otherwise, false for portrait orientation.

Gets or sets the text that will be printed near the bottom left corner of the page.

C#
[Browsable(true)]
public string LeftFooter { get; set; }

Gets or sets the text that will be printed near the upper left corner of the page.

C#
[Browsable(true)]
public string LeftHeader { get; set; }

Gets or sets the logo image that will be printed when the [Logo] placeholder is used in headers or footers.

C#
[Browsable(true)]
public Image Logo { get; set; }
Property Value:

An Image representing the logo, or null if no logo is set.

Gets or sets the margins for the printed page.

C#
[Browsable(true)]
public Margins Margins { get; set; }
Property Value:

A Margins object that represents the page margins, or null to use the default.

Gets or sets the text that will be printed at the bottom center of the page.

C#
[Browsable(true)]
public string MiddleFooter { get; set; }

Gets or sets the text that will be printed at the top center of the page.

C#
[Browsable(true)]
public string MiddleHeader { get; set; }

Gets the total page count. The value is populated when the printing process begins.

C#
[Browsable(false)]
public int PageCount { get; }

Gets or sets the paper size for printing.

C#
[Browsable(true)]
public PaperSize PaperSize { get; set; }
Property Value:

A PaperSize object that represents the size of the paper, or null to use the default.

Gets or sets the paper source (tray) from which to get the paper.

C#
[Browsable(true)]
public PaperSource PaperSource { get; set; }
Property Value:

A PaperSource object that represents the paper source, or null to use the default.

Gets the number of the page being printed. The value of this property changes during the printing process.

C#
[Browsable(false)]
public int PrintedPage { get; }

Gets or sets a value indicating whether the left and right footer positions should be reversed on even pages.

C#
[Browsable(true)]
public bool ReverseFooterOnEvenPages { get; set; }
Property Value:

true to reverse the footer positions on even pages; otherwise, false.

Gets or sets a value indicating whether the left and right header positions should be reversed on even pages.

C#
[Browsable(true)]
public bool ReverseHeaderOnEvenPages { get; set; }
Property Value:

true to reverse the header positions on even pages; otherwise, false.

Gets or sets the text that will be printed near the bottom right corner of the page.

C#
[Browsable(true)]
public string RightFooter { get; set; }

Gets or sets the text that will be printed near the upper right corner of the page.

C#
[Browsable(true)]
public string RightHeader { get; set; }

Gets or sets the count of the selected pages. This indicates how many pages will be printed when the PrintRange is set to Selection.

C#
[Browsable(false)]
public int SelectionLength { get; set; }

Gets or sets the watermark settings for the printed pages.

C#
[Browsable(true)]
public RadPrintWatermark Watermark { get; set; }
Property Value:

A RadPrintWatermark object that defines the watermark properties, or null if no watermark is used.

Methods

Determines whether the specified string contains the logo placeholder token.

C#
protected bool HasLogoInHeaderFooterString(string s)
Parameters:sstring

The string to check for the logo placeholder.

Returns:

bool

true if the string contains the logo placeholder; otherwise, false.

Called when the associated printable object has changed.

C#
protected virtual void OnAssociatedObjectChanged()

Handles the beginning of the print job by initializing the page count and setting up print parameters.

C#
protected override void OnBeginPrint(PrintEventArgs e)
Parameters:ePrintEventArgs

A PrintEventArgs that contains the event data.

Overrides: PrintDocument.OnBeginPrint(PrintEventArgs)

Handles the end of the print job by finalizing the printing process and cleaning up resources.

C#
protected override void OnEndPrint(PrintEventArgs e)
Parameters:ePrintEventArgs

A PrintEventArgs that contains the event data.

Overrides: PrintDocument.OnEndPrint(PrintEventArgs)

Handles the printing of each page by coordinating the watermark, content, header, and footer rendering.

C#
protected override void OnPrintPage(PrintPageEventArgs e)
Parameters:ePrintPageEventArgs

A PrintPageEventArgs that contains the event data.

Overrides: PrintDocument.OnPrintPage(PrintPageEventArgs)

Parses a header or footer string by replacing placeholder tokens with their actual values.

C#
protected string ParseHeaderFooterString(string s)
Parameters:sstring

The string containing placeholder tokens to be replaced.

Returns:

string

The parsed string with placeholders replaced by actual values.

Prints the footer part of the page.

C#
protected virtual void PrintFooter(PrintPageEventArgs args)
Parameters:argsPrintPageEventArgs

The printing arguments.

Prints the header part of the page.

C#
protected virtual void PrintHeader(PrintPageEventArgs args)
Parameters:argsPrintPageEventArgs

The printing arguments.

Renders the logo image within the specified rectangle.

C#
protected virtual void PrintLogo(Graphics g, Rectangle rect)
Parameters:gGraphics

The Graphics object to draw on.

rectRectangle

The Rectangle area where the logo should be drawn.

Prints the watermark of the page.

C#
protected virtual void PrintWatermark(PrintPageEventArgs args)
Parameters:argsPrintPageEventArgs

The printing arguments.