Skip to main content
All docs
V25.1
  • Section.PageBorders Property

    Stores page border settings.

    Namespace: DevExpress.XtraRichEdit.API.Native

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

    NuGet Package: DevExpress.RichEdit.Core

    Declaration

    SectionPageBorders PageBorders { get; }

    Property Value

    Type Description
    SectionPageBorders

    A SectionPageBorders object that contains page border settings.

    Example

    The following code snippet adds page borders to two sections:

    • In the first section, page borders are shown only on the first page.
    • In the second section, page borders are shown on all pages.
    using DevExpress.XtraRichEdit;
    using DevExpress.XtraRichEdit.API.Native;
    using System.Diagnostics;
    using System.Drawing;
    
    string fileName = "Test.docx";
    using (var wordProcessor = new RichEditDocumentServer()) {
        Document document = wordProcessor.Document;
        // Generate a document with two sections and multiple pages in each section.
        document.AppendText("\f\f\f");
        document.Paragraphs.Append();
        document.AppendSection();
        document.AppendText("\f\f");
    
        Section firstSection = document.Sections[0];
        SectionPageBorders pageBorders1 = firstSection.PageBorders;
    
        // Set page borders for the first page of the first section.
        SetPageBorders(pageBorders1.LeftBorder, BorderLineStyle.Single, 1f, Color.Red);
        SetPageBorders(pageBorders1.TopBorder, BorderLineStyle.Single, 1f, Color.Red);
        SetPageBorders(pageBorders1.RightBorder, BorderLineStyle.Single, 1f, Color.Red);
        SetPageBorders(pageBorders1.BottomBorder, BorderLineStyle.Single, 1f, Color.Red);
        pageBorders1.AppliesTo = PageBorderAppliesTo.FirstPage;
    
        Section secondSection = document.Sections[1];
        SectionPageBorders pageBorders2 = secondSection.PageBorders;
    
        // Set page borders for all pages of the second section.
        SetPageBorders(pageBorders2.LeftBorder, BorderLineStyle.Double, 1.5f, Color.Green);
        SetPageBorders(pageBorders2.TopBorder, BorderLineStyle.Double, 1.5f, Color.Green);
        SetPageBorders(pageBorders2.RightBorder, BorderLineStyle.Double, 1.5f, Color.Green);
        SetPageBorders(pageBorders2.BottomBorder, BorderLineStyle.Double, 1.5f, Color.Green);
        pageBorders2.AppliesTo = PageBorderAppliesTo.AllPages;
        pageBorders2.ZOrder = PageBorderZOrder.Back;
    
        wordProcessor.SaveDocument(fileName, DocumentFormat.Docx);
    }
    void SetPageBorders(PageBorder border, BorderLineStyle lineStyle,
        float borderWidth, Color color) {
            border.LineStyle = lineStyle;
            border.LineWidth = borderWidth;
            border.LineColor = color;
        }
    
    Process.Start(new ProcessStartInfo(fileName) { UseShellExecute = true });
    

    The following picture shows the resulting page borders:

    Word Processing API - Page Borders for Sections

    The following code snippet (auto-collected from DevExpress Examples) contains a reference to the PageBorders property.

    Note

    The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

    See Also