Export (0) Print
Expand All

PageSettings Class

Specifies settings that apply to a single, printed page.

System.Object
  System.Drawing.Printing.PageSettings

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

[SerializableAttribute]
public class PageSettings : ICloneable

The PageSettings type exposes the following members.

  NameDescription
Public methodPageSettings()Initializes a new instance of the PageSettings class using the default printer.
Public methodPageSettings(PrinterSettings)Initializes a new instance of the PageSettings class using a specified printer.
Top

  NameDescription
Public propertyBoundsGets the size of the page, taking into account the page orientation specified by the Landscape property.
Public propertyColorGets or sets a value indicating whether the page should be printed in color.
Public propertyHardMarginXGets the x-coordinate, in hundredths of an inch, of the hard margin at the left of the page.
Public propertyHardMarginYGets the y-coordinate, in hundredths of an inch, of the hard margin at the top of the page.
Public propertyLandscapeGets or sets a value indicating whether the page is printed in landscape or portrait orientation.
Public propertyMarginsGets or sets the margins for this page.
Public propertyPaperSizeGets or sets the paper size for the page.
Public propertyPaperSourceGets or sets the page's paper source; for example, the printer's upper tray.
Public propertyPrintableAreaGets the bounds of the printable area of the page for the printer.
Public propertyPrinterResolutionGets or sets the printer resolution for the page.
Public propertyPrinterSettingsGets or sets the printer settings associated with the page.
Top

  NameDescription
Public methodCloneCreates a copy of this PageSettings.
Public methodCopyToHdevmodeCopies the relevant information from the PageSettings to the specified DEVMODE structure.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodSetHdevmodeCopies relevant information to the PageSettings from the specified DEVMODE structure.
Public methodToStringInfrastructure. Converts the PageSettings to string form. (Overrides Object.ToString().)
Top

The PageSettings class is used to specify settings that modify the way a page will be printed. Typically, you set default settings for all pages to be printed through the PrintDocument.DefaultPageSettings property. To specify settings on a page-by-page basis, handle the PrintDocument.PrintPage or PrintDocument.QueryPageSettings event and modify the PageSettings argument included in the PrintPageEventArgs or QueryPageSettingsEventArgs, respectively.

For more information about handling PrintDocument events, see the PrintDocument class overview. For more information about printing, see the System.Drawing.Printing namespace overview.

The following example demonstrates handling the PrintPage event and checking the PageSettings argument of PrintPageEventArgs. To use this code, add a PrintDocument component named PrintDocument1 to a Windows Form and associate its PrintPage event with the printDocument1_PrintPage method in the example.

private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e)
{
    if (e.PageSettings.Color && !printDocument1.PrinterSettings.SupportsColor)
        MessageBox.Show("Color printing not supported on selected printer.", "Printer Warning", MessageBoxButtons.OKCancel);
}

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft