Version

PagePrinting Event

Fired before the page is rendered
Syntax
'Declaration
 
Public Event PagePrinting As PagePrintingEventHandler
public event PagePrintingEventHandler PagePrinting
Event Data

The event handler receives an argument of type PagePrintingEventArgs containing data related to this event. The following PagePrintingEventArgs properties provide information specific to this event.

PropertyDescription
Cancel Returns or sets whether the print operation should be cancelled.
Document (Inherited from Infragistics.Win.Printing.PageSectionPrintEventArgs)Returns the document that is being rendered.
Graphics (Inherited from Infragistics.Win.Printing.PageSectionPrintEventArgs)Returns the graphics object into which the page should be rendered
Handled Returns or sets whether the default rendering should occur for the page background and border.
PageSettings (Inherited from Infragistics.Win.Printing.PageSectionPrintEventArgs)Returns the System.Drawing.Printing.PageSettings associated with the current page being printed.
RectInsideBorders (Inherited from Infragistics.Win.Printing.PageSectionPrintEventArgs)Returns the area of the section within its borders
RectInsideMargins (Inherited from Infragistics.Win.Printing.PageSectionPrintEventArgs)Returns the area of the section within its margins
RectInsidePadding (Inherited from Infragistics.Win.Printing.PageSectionPrintEventArgs)Returns the area of the section inside the borders.
RectOverall (Inherited from Infragistics.Win.Printing.PageSectionPrintEventArgs)Returns the area available for the section.
Example
The following example demonstrates the 'PagePrinting' event of the UltraPrintDocument.

For an overview of how to handle events in Visual Basic or Visual C#, see Event Handlers in Visual Basic and Visual C#. For specific information and code examples illustrating how to consume events in your application, see Consuming Events in the .NET Framework Developer's Guide.

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

    Private Sub UltraPrintDocument1_PagePrinting(ByVal sender As System.Object, ByVal e As Infragistics.Win.Printing.PagePrintingEventArgs) Handles UltraPrintDocument1.PagePrinting
        ' the page printing event can be used to cancel the print 
        ' operation completely or used to adjust some settings of 
        ' the various page sections. for example, if you were 
        ' inserting a title page, you probably wouldn't want
        ' the header or footer to render, so you can explicitly
        ' set their height to 0
        If e.Document.PageNumber = 1 Then
            e.Document.Header.Height = 0
            e.Document.Footer.Height = 0
        Else e.Document.PageNumber = 1 Then
            ' then for all subsequent pages, the header and
            ' footer height should be automatically calculated
            ' based on the contents (text, padding, border, margins,etc).
            e.Document.Header.Height = -1
            e.Document.Footer.Height = -1
        End If
    End Sub
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.Printing;

		private void ultraPrintDocument1_PagePrinting(object sender, Infragistics.Win.Printing.PagePrintingEventArgs e)
		{
			// the page printing event can be used to cancel the print 
			// operation completely or used to adjust some settings of 
			// the various page sections. for example, if you were 
			// inserting a title page, you probably wouldn't want
			// the header or footer to render, so you can explicitly
			// set their height to 0
			if (e.Document.PageNumber == 1)
			{
				e.Document.Header.Height = 0;
				e.Document.Footer.Height = 0;
			}
			else (e.Document.PageNumber == 1)
			{
				// then for all subsequent pages, the header and
				// footer height should be automatically calculated
				// based on the contents (text, padding, border, margins,etc).
				e.Document.Header.Height = -1;
				e.Document.Footer.Height = -1;
			}
		}
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