Class Margins
Margins to use for printing (in millimeters).
Inheritance
Namespace: IronPrint
Assembly: IronPrint.dll
Syntax
public sealed class Margins : ValueType
The blank space around printed content on each edge of the sheet lives in a Margins value, measured in millimeters. Set wider margins to meet binding or letterhead requirements, or tighter ones to fit more on the page. A Margins value is assigned to PrintSettings.PaperMargins and applied to the print driver before the page renders, so the output matches the chosen spacing regardless of the printer's own defaults.
Build one with the constructor that fits the job. Margins(int uniformMargin) applies an equal margin to all four sides. Margins(int horizontal, int vertical) sets matched left and right, top and bottom pairs. Margins(int left, int top, int right, int bottom) gives full control of each edge. The static Margins.Zero returns a borderless layout with every edge at zero.
After construction, the Left, Top, Right, and Bottom properties expose each edge for reading or adjustment. Because PaperMargins is a Nullable<Margins> on PrintSettings, leaving it null keeps the printer's own default margins; assign a Margins value only when a document needs specific spacing. The set paper margins guide shows the property in a complete print job.
using IronPrint;
PrintSettings settings = new PrintSettings
{
PaperMargins = new Margins(20, 15, 20, 15)
};The print settings guide covers the other options margins combine with, and the paper size guide pairs sheet dimensions with margin spacing.
Constructors
Margins(Int32)
Margins to use for printing with the same value for all sides (in millimeters).
Declaration
public Margins(int uniformMargin)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | uniformMargin | The margin value to apply to all sides (left, top, right, and bottom). |
Margins(Int32, Int32)
Margins for printing.
Declaration
public Margins(int horizontal, int vertical)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | horizontal | Margins for left and right side of page. |
| System.Int32 | vertical | Margins for top and bottom of page. |
Margins(Int32, Int32, Int32, Int32)
Margins for printing.
Declaration
public Margins(int left, int top, int right, int bottom)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | left | The left margin (in millimeters). |
| System.Int32 | top | The top margin (in millimeters). |
| System.Int32 | right | The right margin (in millimeters). |
| System.Int32 | bottom | The bottom margin (in millimeters). |
Fields
Bottom
Bottom margin.
Declaration
public int Bottom
Field Value
| Type | Description |
|---|---|
| System.Int32 |
Left
Left margin.
Declaration
public int Left
Field Value
| Type | Description |
|---|---|
| System.Int32 |
Right
Right margin.
Declaration
public int Right
Field Value
| Type | Description |
|---|---|
| System.Int32 |
Top
Top margin.
Declaration
public int Top
Field Value
| Type | Description |
|---|---|
| System.Int32 |
Zero
No margins.
Declaration
public static Margins Zero
Field Value
| Type | Description |
|---|---|
| Margins |