Version

UltraPrintDocument Class

Base class for rendering a print document with a page header and/or footer.
Syntax
'Declaration
 
Public Class UltraPrintDocument 
   Inherits System.Drawing.Printing.PrintDocument
public class UltraPrintDocument : System.Drawing.Printing.PrintDocument 
Remarks

The UltraPrintDocument is a specialized System.Drawing.Printing.PrintDocument that adds built-in support for custom page headers and footers (see the Header and Footer).

Property settings may be saved using the SaveAsXml(Stream) and SaveAsBinary(Stream) methods. These serialized settings may then be loaded using the LoadFromXml(Stream) and LoadFromBinary(Stream) methods respectively.

Property settings of the base PrintDocument class, including the System.Drawing.Printing.PrintDocument.DefaultPageSettings are not serialized when using the SaveAsXml and SaveAsBinary methods.

Example
The following example demonstrates some of the properties of the UltraPrintDocument and its associated PageSection objects.

Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.Printing

        ' the print document exposes a 'PrintColorStyle' although
        ' it is up to the implementation to honor this. the default
        ' appearances and pagesections will honor this setting
        Me.UltraPrintDocument1.PrintColorStyle = ColorRenderMode.GrayScale

        ' the header and footer can have text aligned within
        ' the section and can include replaceable tokens
        Me.UltraPrintDocument1.Header.TextLeft = "[User Name]"
        Me.UltraPrintDocument1.Header.TextCenter = Me.UltraPrintDocument1.DocumentName
        Me.UltraPrintDocument1.Header.TextRight = "[Date Printed]"

        ' the header is a derived page section and therefore
        ' can have a border and control over which sides render
        ' the border
        Me.UltraPrintDocument1.Header.BorderStyle = UIElementBorderStyle.Solid
        Me.UltraPrintDocument1.Header.BorderSides = Border3DSide.Bottom

        ' initialize the text that will appear in the footer.
        ' this can be replaceable tokens that will insert the
        ' time, page number, etc.
        Me.UltraPrintDocument1.Footer.TextLeft = "[Time Printed]"
        Me.UltraPrintDocument1.Footer.TextRight = "[Page #]"

        ' the height of the section will be calculated automatically
        ' based on the contents but may be explicitly controlled
        ' using the height property
        'this.ultraPrintDocument1.Footer.Height

        ' the section text can be setup to switch on 
        ' alternate pages
        Me.UltraPrintDocument1.Footer.ReverseTextOnEvenPages = True

        ' add extra space our the page body
        Me.UltraPrintDocument1.PageBody.Margins.Top = 5
        Me.UltraPrintDocument1.PageBody.Margins.Bottom = 5

        ' the page property is the section representing the
        ' entire renderable area of the page. you can assign
        ' a border around the margin area
        Me.UltraPrintDocument1.Page.BorderStyle = UIElementBorderStyle.Solid

        ' and then use the padding to provide space between the
        ' border and contents (header, footer, pagebody)
        Me.UltraPrintDocument1.Page.Padding.Left = 2
        Me.UltraPrintDocument1.Page.Padding.Right = 2
        Me.UltraPrintDocument1.Page.Padding.Top = 2
        Me.UltraPrintDocument1.Page.Padding.Bottom = 2

        ' the appearance of the page will affect only the page itself
        Me.UltraPrintDocument1.Page.Appearance.BorderColor = Color.Black

        ' the appearance property will affect all sections
        Me.UltraPrintDocument1.Appearance.ForeColor = Color.Black
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.Printing;

			// the print document exposes a 'PrintColorStyle' although
			// it is up to the implementation to honor this. the default
			// appearances and pagesections will honor this setting
			this.ultraPrintDocument1.PrintColorStyle = ColorRenderMode.GrayScale;

			// the header and footer can have text aligned within
			// the section and can include replaceable tokens
			this.ultraPrintDocument1.Header.TextLeft = "[User Name]";
			this.ultraPrintDocument1.Header.TextCenter = this.ultraPrintDocument1.DocumentName;
			this.ultraPrintDocument1.Header.TextRight = "[Date Printed]";

			// the header is a derived page section and therefore
			// can have a border and control over which sides render
			// the border
			this.ultraPrintDocument1.Header.BorderStyle = UIElementBorderStyle.Solid;
			this.ultraPrintDocument1.Header.BorderSides = Border3DSide.Bottom;

			// initialize the text that will appear in the footer.
			// this can be replaceable tokens that will insert the
			// time, page number, etc.
			this.ultraPrintDocument1.Footer.TextLeft = "[Time Printed]";
			this.ultraPrintDocument1.Footer.TextRight = "[Page #]";

			// the height of the section will be calculated automatically
			// based on the contents but may be explicitly controlled
			// using the height property
			//this.ultraPrintDocument1.Footer.Height

			// the section text can be setup to switch on 
			// alternate pages
			this.ultraPrintDocument1.Footer.ReverseTextOnEvenPages = true;

			// add extra space our the page body
			this.ultraPrintDocument1.PageBody.Margins.Top = 5;
			this.ultraPrintDocument1.PageBody.Margins.Bottom = 5;

			// the page property is the section representing the
			// entire renderable area of the page. you can assign
			// a border around the margin area
			this.ultraPrintDocument1.Page.BorderStyle = UIElementBorderStyle.Solid;

			// and then use the padding to provide space between the
			// border and contents (header, footer, pagebody)
			this.ultraPrintDocument1.Page.Padding.Left = 2;
			this.ultraPrintDocument1.Page.Padding.Right = 2;
			this.ultraPrintDocument1.Page.Padding.Top = 2;
			this.ultraPrintDocument1.Page.Padding.Bottom = 2;

			// the appearance of the page will affect only the page itself
			this.ultraPrintDocument1.Page.Appearance.BorderColor = Color.Black;

			// the appearance property will affect all sections
			this.ultraPrintDocument1.Appearance.ForeColor = Color.Black;
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also