Click or drag to resize
Pdf Library for .NET

PdfMargins Class

Represents the margins (in points) of a PDF page or element. Used, for example, when adding a page with Add(PdfCustomPageSize, PdfMargins) or when configuring the conversion output.
Inheritance Hierarchy
SystemObject
  SelectPdf.UniversalPdfMargins

Namespace: SelectPdf.Universal
Assembly: SelectPdf.HtmlToPdf.Universal (in SelectPdf.HtmlToPdf.Universal.dll) Version: 26.4
Syntax
public class PdfMargins

The PdfMargins type exposes the following members.

Constructors
 NameDescription
Public methodPdfMargins Initializes a new instance of the PdfMargins class with all margins set to zero.
Public methodPdfMargins(Single) Initializes a new instance of the PdfMargins class with all margins set to the same value.
Public methodPdfMargins(Single, Single, Single, Single) Initializes a new instance of the PdfMargins class with the specified margin values.
Top
Properties
 NameDescription
Public propertyBottom Gets or sets the bottom margin in points.
Public propertyStatic memberEmpty Gets a PdfMargins with all margins set to zero.
Public propertyLeft Gets or sets the left margin in points.
Public propertyRight Gets or sets the right margin in points.
Public propertyTop Gets or sets the top margin in points.
Top
Example
// Add a page with a uniform 40-point margin, then a page with individual margins.
PdfDocument document = new PdfDocument();
document.Pages.Add(PdfCustomPageSize.A4, new PdfMargins(40));
document.Pages.Add(PdfCustomPageSize.A4, new PdfMargins(20, 20, 50, 30));
document.Save("margins.pdf");
document.Close();
See Also