officefileapi-devexpress-dot-xtrarichedit-dot-api-dot-native-dot-section-ad501e56.md
Stores page border settings.
Namespace : DevExpress.XtraRichEdit.API.Native
Assembly : DevExpress.RichEdit.v25.2.Core.dll
NuGet Package : DevExpress.RichEdit.Core
SectionPageBorders PageBorders { get; }
ReadOnly Property PageBorders As SectionPageBorders
| Type | Description |
|---|---|
| SectionPageBorders |
A SectionPageBorders object that contains page border settings.
|
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 });
Imports DevExpress.XtraRichEdit
Imports DevExpress.XtraRichEdit.API.Native
Imports System.Diagnostics
Imports System.Drawing
Private fileName As String = "Test.docx"
Using wordProcessor = New RichEditDocumentServer()
Dim document As Document = wordProcessor.Document
' Generate a document with two sections and multiple pages in each section.
Private Sub SurroundingSub()
document.AppendText(vbFormFeed & vbFormFeed & vbFormFeed)
document.Paragraphs.Append()
document.AppendSection()
document.AppendText(vbFormFeed & vbFormFeed)
End Sub
Dim firstSection As Section = document.Sections(0)
Dim pageBorders1 As SectionPageBorders = 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
Dim secondSection As Section = document.Sections(1)
Dim pageBorders2 As SectionPageBorders = 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)
End Using
Private Sub SetPageBorders(ByVal border As PageBorder, ByVal lineStyle As BorderLineStyle, ByVal borderWidth As Single, ByVal color As Color)
border.LineStyle = lineStyle
border.LineWidth = borderWidth
border.LineColor = color
End Sub
Process.Start(New ProcessStartInfo(fileName) With {.UseShellExecute = True})
The following picture shows the resulting page borders:
The following code snippets (auto-collected from DevExpress Examples) contain references 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.
wpf-richedit-document-api/CS/DXRichEditControlAPISample/CodeExamples/PageLayoutActions.cs#L78
Section firstSection = document.Sections[0];
SectionPageBorders pageBorders1 = firstSection.PageBorders;
winforms-richedit-document-api/CS/RichEditAPISample/CodeExamples/PageLayout.cs#L78
Section firstSection = document.Sections[0];
SectionPageBorders pageBorders1 = firstSection.PageBorders;
word-document-api-examples/CS/CodeExamples/PageLayoutActions.cs#L134
Section firstSection = document.Sections[0];
SectionPageBorders pageBorders1 = firstSection.PageBorders;
wpf-richedit-document-api/VB/DXRichEditControlAPISample/CodeExamples/PageLayoutActions.vb#L65
Dim firstSection As DevExpress.XtraRichEdit.API.Native.Section = document.Sections(0)
Dim pageBorders1 As DevExpress.XtraRichEdit.API.Native.SectionPageBorders = firstSection.PageBorders
' Set page borders for the first page of the first section.
winforms-richedit-document-api/VB/RichEditAPISample/CodeExamples/PageLayout.vb#L72
Dim firstSection As DevExpress.XtraRichEdit.API.Native.Section = document.Sections(0)
Dim pageBorders1 As DevExpress.XtraRichEdit.API.Native.SectionPageBorders = firstSection.PageBorders
' Set page borders for the first page of the first section.
See Also