Back to Devexpress

Document.MarginType Property

officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-document-177574f3.md

latest3.3 KB
Original Source

Document.MarginType Property

Specifies the type of margins used in the document.

Namespace : DevExpress.XtraRichEdit.API.Native

Assembly : DevExpress.RichEdit.v25.2.Core.dll

NuGet Package : DevExpress.RichEdit.Core

Declaration

csharp
MarginType MarginType { get; set; }
vb
Property MarginType As MarginType

Property Value

TypeDescription
MarginType

An enumeration value that indicates the margin type.

|

Available values:

NameDescription
Normal

Normal margins

| | Mirrored |

Mirrored margins.

|

Remarks

The MarginType property defines the margin type: regular or mirrored. Mirrored margins add extra space to inside and outside margins of facing pages to create a symmetrical appearance.

The SectionMargins.Gutter property specifies the mirror margin value. When the MarginsType property is set to Mirrored, the SectionMargins.GutterPosition property is ignored.

Example

The following code sample enables mirrored margins and specifies an additional space value:

csharp
using DevExpress.XtraRichEdit;
using DevExpress.XtraRichEdit.API.Native;
using DevExpress.Office.Utils;

using (var wordProcessor = new RichEditDocumentServer())
{
    wordProcessor.LoadDocument(@"Documents//Alice.docx");

    Document document = wordProcessor.Document;

    // Enable mirrored margins
    document.MarginsType = MarginsType.Mirrored;

    foreach (Section section in wordProcessor.Document.Sections)
    {
        var pageMargins = section.Margins;

        // Set the value for mirrored margins
        pageMargins.Gutter = Units.InchesToDocumentsF(0.5f);
    }

    wordProcessor.SaveDocument("Alice_formatted.docx", DocumentFormat.Docx);   
}
vb
Imports DevExpress.XtraRichEdit
Imports DevExpress.XtraRichEdit.API.Native
Imports DevExpress.Office.Utils

Using wordProcessor = New RichEditDocumentServer()
    wordProcessor.LoadDocument("Documents//Alice.docx")

    Dim document As Document = wordProcessor.Document

    ' Enable mirrored margins
    document.MarginsType = MarginsType.Mirrored

    For Each section As Section In wordProcessor.Document.Sections
        Dim pageMargins = section.Margins

        ' Set the value for mirrored margins
        pageMargins.Gutter = Units.InchesToDocumentsF(0.5F)
    Next section

    wordProcessor.SaveDocument("Alice_formatted.docx", DocumentFormat.Docx)
End Using

See Also

Document Interface

Document Members

DevExpress.XtraRichEdit.API.Native Namespace