Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

PageSettings Class

Specifies settings that apply to a single, printed page.

For a list of all members of this type, see PageSettings Members.


[Visual Basic]
Public Class PageSettings
   Implements ICloneable
public class PageSettings : ICloneable
public __gc class PageSettings : public ICloneable
class PageSettings implements ICloneable

Thread Safety

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


This 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 on handling PrintDocument events, see the PrintDocument class overview. For more information on printing, see the System.Drawing.Printing namespace overview.


[Visual Basic, C#, C++] The following example sets the document's default page orientation to landscape through the PrintDocument.DefaultPageSettings property, and prints the document using the Print method. The example makes three assumptions: that a variable named filePath has been set to the path of the file to print; that a method named pd_PrintPage, which handles the PrintPage event, has been defined; and that a variable named printer has been set to the printer's name.

[Visual Basic, C#, C++] Use the System.Drawing, System.Drawing.Printing, and System.IO namespaces for this example.

[Visual Basic] 
Public Sub Printing()
        streamToPrint = New StreamReader(filePath)
            printFont = New Font("Arial", 10)
            Dim pd As New PrintDocument()
            AddHandler pd.PrintPage, AddressOf pd_PrintPage
            pd.PrinterSettings.PrinterName = printer
            ' Set the page orientation to landscape.
            pd.DefaultPageSettings.Landscape = True
        End Try
    Catch ex As Exception
    End Try
End Sub

public void Printing() {
   try {
     streamToPrint = new StreamReader (filePath);
     try {
       printFont = new Font("Arial", 10);
       PrintDocument pd = new PrintDocument(); 
       pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
       pd.PrinterSettings.PrinterName = printer;
       // Set the page orientation to landscape.
       pd.DefaultPageSettings.Landscape = true;
     finally {
       streamToPrint.Close() ;
   catch(Exception ex) { 

void Printing() {
   try {
     streamToPrint = new StreamReader (filePath);
     try {
       printFont = new Font(S"Arial", 10);
       PrintDocument* pd = new PrintDocument(); 
       pd->PrintPage += new PrintPageEventHandler(this, &Sample::pd_PrintPage);
       pd->PrinterSettings->PrinterName = printer;
       // Set the page orientation to landscape.
       pd->DefaultPageSettings->Landscape = true;
     __finally {
       streamToPrint->Close() ;
   catch(Exception* ex) { 

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Namespace: System.Drawing.Printing

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

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

See Also

PageSettings Members | System.Drawing.Printing Namespace | PrintDocument | PrinterSettings

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft. All rights reserved.