Specifies the dimensions of the margins of a printed page.
Assembly: System.Drawing (in System.Drawing.dll)
Thetype exposes the following members.
|Clone||Retrieves a duplicate of this object, member by member.|
|Equals||Compares this to the specified Object to determine whether they have the same dimensions. (Overrides Object.Equals(Object).)|
|Finalize||Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)|
|GetHashCode||Calculates and retrieves a hash code based on the width of the left, right, top, and bottom margins. (Overrides Object.GetHashCode.)|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|MemberwiseClone||Creates a shallow copy of the current Object. (Inherited from Object.)|
|ToString||Infrastructure. Converts the to a string. (Overrides Object.ToString.)|
For more information about printing, see the System.Drawing.Printing namespace overview.
The following code example sets the default page settings for a document to margins of 1 inch on each side.
Public Sub Printing() Try ' This assumes that a variable of type string, named filePath, ' has been set to the path of the file to print. streamToPrint = New StreamReader(filePath) Try printFont = New Font("Arial", 10) Dim pd As New PrintDocument() ' This assumes that a method, named pd_PrintPage, has been ' defined. pd_PrintPage handles the PrintPage event. AddHandler pd.PrintPage, AddressOf pd_PrintPage ' This assumes that a variable of type string, named ' printer, has been set to the printer's name. pd.PrinterSettings.PrinterName = printer ' Create a new instance of Margins with one inch margins. Dim margins As New Margins(100, 100, 100, 100) pd.DefaultPageSettings.Margins = margins pd.Print() Finally streamToPrint.Close() End Try Catch ex As Exception MessageBox.Show("An error occurred printing the file - " & ex.Message) End Try End Sub