TextColumn class

TextColumn class

Represents a single text column. TextColumn is a member of the TextColumnCollection collection. The TextColumn collection includes all the columns in a section of a document. To learn more, visit the Working with Sections documentation article.


TextColumn objects are only used to specify columns with custom width and spacing. If you want the columns in the document to be of equal width, set TextColumns.TextColumnCollection.evenly_spaced to True.

When a new TextColumn is created it has its width and spacing set to zero.


space_afterGets or sets the space between this column and the next column in points. Not required for the last column.
widthGets or sets the width of the text column in points.


Shows how to create unevenly spaced columns.

doc = aw.Document()
builder = aw.DocumentBuilder(doc)
page_setup = builder.page_setup
columns = page_setup.text_columns
columns.evenly_spaced = False
# Determine the amount of room that we have available for arranging columns.
content_width = page_setup.page_width - page_setup.left_margin - page_setup.right_margin
self.assertAlmostEqual(470.3, content_width, delta=0.01)
# Set the first column to be narrow.
column = columns[0]
column.width = 100
column.space_after = 20
# Set the second column to take the rest of the space available within the margins of the page.
column = columns[1]
column.width = content_width - column.width - column.space_after
builder.writeln('Narrow column 1.')
builder.writeln('Wide column 2.')
doc.save(file_name=ARTIFACTS_DIR + 'PageSetup.CustomColumnWidth.docx')

See Also