Developers can add borders to all pages in a Section using Aspose.Pdf . There are two properties in Section class related to handling borders:
PageInfo.PageBorder property of Section class is used to set the borders of pages in a Section . This property takes an instance of BorderInfo and BorderInfo object keeps all information related to page border.
PageInfo.PageBorderMargin property of Section class is used to set the margins between the page border and page edge. The default value of PageBorderMargin is half of the page margin. Infact, PageBorderMargin property is an instance of MarginInfo class and has further properties like:
The above four properties provide complete control to set any margin area of the page.
Example:
[C#]
//Add a section to the Pdf document
Section sec1 = pdf1.Sections.Add();
//Set the page border of the section using BorderInfo object
sec1.PageInfo.PageBorder = new BorderInfo((int)BorderSide.All,0.2F);
//Set the left margin of page border of the section
sec1.PageInfo.PageBorderMargin.Left = 20;
//Add a text paragraph to the paragraphs collection of the section
sec1.Paragraphs.Add(new Text("Hello World"));
[VB.NET]
'Add a section to the Pdf document
Dim sec1 As Section = pdf1.Sections.Add()
'Set the page border of the section using BorderInfo object
sec1.PageInfo.PageBorder = New BorderInfo(BorderSide.All, 0.2)
'Set the left margin of page border of the section
sec1.PageInfo.PageBorderMargin.Left = 20
'Add a text paragraph to the paragraphs collection of the section
sec1.Paragraphs.Add(New Text("Hello World"))
[XML]
<Section PageBorderMarginLeft="20">
<PageBorder>
<All LineWidth="0.2"></All>
</PageBorder>
<Text>
<Segment>Hello World</Segment>
</Text>
</Section>