Skip to main content
All docs
V25.1
  • DevExpress v25.1 Update — Your Feedback Matters

    Our What's New in v25.1 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

    Take the survey Not interested

    SectionPageBorders Interface

    Provides access to page border settings in a Section.

    Namespace: DevExpress.XtraRichEdit.API.Native

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

    NuGet Package: DevExpress.RichEdit.Core

    #Declaration

    [ComVisible(true)]
    public interface SectionPageBorders

    The following members return SectionPageBorders objects:

    #Remarks

    This class introduces the SectionPageBorders.TopBorder, SectionPageBorders.BottomBorder, SectionPageBorders.RightBorder and SectionPageBorders.LeftBorder properties, which specify section page borders.

    #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

    See Also