Independentsoft
Professional software libraries for developers
Home
Purchase
Support
Company
Contact
ODF .NET
>
Tutorial
> Paragraph border
The following example shows how to add a border around a paragraph.
C# example
using System; using Independentsoft.Office.Odf; using Independentsoft.Office.Odf.Styles; namespace Sample { class Program { static void Main(string[] args) { TextDocument doc = new TextDocument(); Border border = new Border(); border.Style = BorderStyle.Solid; border.Width = new Size(1, Unit.Millimeter); border.Color = "#000000"; ParagraphStyle boxStyle = new ParagraphStyle("BoxStyle"); boxStyle.ParagraphProperties.Border = border; boxStyle.ParagraphProperties.Padding = new Size(3, Unit.Millimeter); doc.AutomaticStyles.Styles.Add(boxStyle); Paragraph p1 = new Paragraph(); p1.Style = "BoxStyle"; p1.Add("This paragraph has a border around it."); doc.Body.Add(p1); Paragraph p2 = new Paragraph(); p2.Add("This paragraph has no border."); doc.Body.Add(p2); doc.Save("c:\\test\\output.odt", true); } } }
VB example
Imports System Imports Independentsoft.Office.Odf Imports Independentsoft.Office.Odf.Styles Module Module1 Sub Main(ByVal args() As String) Dim doc As TextDocument = New TextDocument Dim border As Border = New Border border.Style = LineStyle.Solid border.Width = New Size(1, Unit.Millimeter) border.Color = "#000000" Dim style1 As ParagraphStyle = New ParagraphStyle("P1") style1.ParagraphProperties.Border = border style1.ParagraphProperties.TopMargin = New Size(3, Unit.Millimeter) style1.ParagraphProperties.BottomMargin = New Size(3, Unit.Millimeter) doc.AutomaticStyles.Styles.Add(style1) Dim p1 As Paragraph = New Paragraph p1.Style = "P1" p1.Add("This paragraph has a solid black border.") doc.Body.Add(p1) doc.Save("c:\test\output.odt", True) End Sub End Module
Need help? Ask our developers:
Name*
Email*
Message*