TextColumnCollection Class |
Represents a collection of text columns in a section.
Inheritance Hierarchy SystemObject System.Collections.ObjectModelReadOnlyCollectionTextColumn SautinSoft.DocumentTextColumnCollection Namespace: SautinSoft.DocumentAssembly: SautinSoft.Document (in SautinSoft.Document.dll) Version: 2024.7.18
Syntax public sealed class TextColumnCollection : ReadOnlyCollection<TextColumn>
Public NotInheritable Class TextColumnCollection
Inherits ReadOnlyCollection(Of TextColumn)
The TextColumnCollection type exposes the following members.
Constructors Properties | Name | Description |
---|
| EvenlySpaced |
Gets or sets a value indicating whether all text columns have equal width and are evenly spaced.
|
| LineBetween |
Gets or sets a value indicating whether to show or not the line between two
TextColumn.
|
| SpaceBetween |
Gets or sets the amount of space between each column (in points).
Set this property only if EvenlySpaced
is .
|
TopExample See Developer Guide: How to work with text columns in a document
How to work with text columns in a document using C#
using SautinSoft.Document;
namespace Sample
{
class Sample
{
static void Main(string[] args)
{
TextColumns();
}
public static void TextColumns()
{
string documentPath = @"TextColumns.docx";
DocumentCore dc = new DocumentCore();
Section s = new Section(dc);
dc.Sections.Add(s);
s.PageSetup.PageMargins = new PageMargins()
{
Top = LengthUnitConverter.Convert(5, LengthUnit.Millimeter, LengthUnit.Point),
Right = LengthUnitConverter.Convert(5, LengthUnit.Millimeter, LengthUnit.Point),
Bottom = LengthUnitConverter.Convert(5, LengthUnit.Millimeter, LengthUnit.Point),
Left = LengthUnitConverter.Convert(5, LengthUnit.Millimeter, LengthUnit.Point)
};
s.PageSetup.TextColumns = new TextColumnCollection(4);
s.PageSetup.TextColumns.EvenlySpaced = false;
s.PageSetup.TextColumns[0].Width = LengthUnitConverter.Convert(60, LengthUnit.Millimeter, LengthUnit.Point);
s.PageSetup.TextColumns[1].Width = LengthUnitConverter.Convert(20, LengthUnit.Millimeter, LengthUnit.Point);
s.PageSetup.TextColumns[2].Width = LengthUnitConverter.Convert(60, LengthUnit.Millimeter, LengthUnit.Point);
s.PageSetup.TextColumns[3].Width = LengthUnitConverter.Convert(20, LengthUnit.Millimeter, LengthUnit.Point);
string text = "Shrek and Donkey arrive at Farquaad's palace in Duloc, where they end up in a tournament. The winner gets the \"privilege\" of rescuing Fiona so that Farquaad may marry her. ";
for (int i = 0; i < 22; i++)
s.Content.End.Insert(text, new CharacterFormat() { FontName = "Arial", Size = 12 });
(s.Blocks[0] as Paragraph).ParagraphFormat.Alignment = HorizontalAlignment.Justify;
dc.Save(documentPath);
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(documentPath) { UseShellExecute = true });
}
}
}
How to work with text columns in a document using VB.Net
Imports System
Imports System.IO
Imports SautinSoft.Document
Module Sample
Sub Main()
TextColumns()
End Sub
Sub TextColumns()
Dim documentPath As String = "TextColumns.docx"
Dim dc As New DocumentCore()
Dim s As New Section(dc)
dc.Sections.Add(s)
s.PageSetup.PageMargins = New PageMargins() With {
.Top = LengthUnitConverter.Convert(5, LengthUnit.Millimeter, LengthUnit.Point),
.Right = LengthUnitConverter.Convert(5, LengthUnit.Millimeter, LengthUnit.Point),
.Bottom = LengthUnitConverter.Convert(5, LengthUnit.Millimeter, LengthUnit.Point),
.Left = LengthUnitConverter.Convert(5, LengthUnit.Millimeter, LengthUnit.Point)
}
s.PageSetup.TextColumns = New TextColumnCollection(4)
s.PageSetup.TextColumns.EvenlySpaced = False
s.PageSetup.TextColumns(0).Width = LengthUnitConverter.Convert(60, LengthUnit.Millimeter, LengthUnit.Point)
s.PageSetup.TextColumns(1).Width = LengthUnitConverter.Convert(20, LengthUnit.Millimeter, LengthUnit.Point)
s.PageSetup.TextColumns(2).Width = LengthUnitConverter.Convert(60, LengthUnit.Millimeter, LengthUnit.Point)
s.PageSetup.TextColumns(3).Width = LengthUnitConverter.Convert(20, LengthUnit.Millimeter, LengthUnit.Point)
Dim text As String = "Shrek and Donkey arrive at Farquaad's palace in Duloc, where they end up in a tournament. The winner gets the ""privilege"" of rescuing Fiona so that Farquaad may marry her. "
For i As Integer = 0 To 21
s.Content.End.Insert(text, New CharacterFormat() With {
.FontName = "Arial",
.Size = 12
})
Next i
TryCast(s.Blocks(0), Paragraph).ParagraphFormat.Alignment = HorizontalAlignment.Justify
dc.Save(documentPath)
System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo(documentPath) With {.UseShellExecute = True})
End Sub
End Module
See Also