This documentation is archived and is not being maintained.

PrintPageEventArgs Class

Provides data for the PrintPage event.

Namespace: System.Drawing.Printing
Assembly: System.Drawing (in system.drawing.dll)

public ref class PrintPageEventArgs : public EventArgs
public class PrintPageEventArgs extends EventArgs
public class PrintPageEventArgs extends EventArgs
Not applicable.

The MarginBounds property retrieves the rectangular area that represents the portion of the page between the margins. The PageBounds property retrieves the rectangular area that represents the total area of the page. The Graphics property defines the graphics object with which to do the painting. The PageSettings property retrieves the printer settings for the current page. The remaining properties indicate whether a print job should be canceled or whether a print job has more pages.

For more information about printing with Windows Forms, see the System.Drawing.Printing namespace overview. If you wish to print from a Windows Presentation Foundation application, see the System.Printing namespace.

The following code example assumes a Button named printButton and a PrintDocument named pd have been created on a Form. Make sure the Click event for the Button is associated with the printButton_Click method and the PrintPage event of the PrintDocument is associated with the pd_PrintPage method in the example. The printButton_Click method from the example calls the Print method raising the PrintPage event, and prints the .bmp file specified in the pd_PrintPage method. To run this example, change the path to the bitmap you want to print.

Use the System.Drawing, System.Drawing.Printing, and System.Windows.Forms namespaces for this example.

No code example is currently available or this language may not be supported.

// Specifies what happens when the user clicks the Button.
 private void printButton_Click(Object sender, EventArgs e)
     try {
     catch (System.Exception ex) {
         MessageBox.Show("An error occurred while printing", ex.ToString());
 } //printButton_Click

 // Specifies what happens when the PrintPage event is raised.
 private void pd_PrintPage(Object sender, PrintPageEventArgs ev)
     // Draw a picture.
         ("C:\\My Folder\\MyFile.bmp"),

     // Indicate that this is the last page to print.
 } //pd_PrintPage


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0