BreakType enumeration

BreakType enumeration

Specifies type of a break inside a document.


PARAGRAPH_BREAKBreak between paragraphs.
PAGE_BREAKExplicit page break.
COLUMN_BREAKExplicit column break.
SECTION_BREAK_CONTINUOUSSpecifies start of new section on the same page as the previous section.
SECTION_BREAK_NEW_COLUMNSpecifies start of new section in the new column.
SECTION_BREAK_NEW_PAGESpecifies start of new section on a new page.
SECTION_BREAK_EVEN_PAGESpecifies start of new section on a new even page.
SECTION_BREAK_ODD_PAGESpecifies start of new section on a odd page.
LINE_BREAKExplicit line break.


Shows how to create headers and footers in a document using DocumentBuilder.

doc = aw.Document()
builder = aw.DocumentBuilder(doc)
# Specify that we want different headers and footers for first, even and odd pages.
builder.page_setup.different_first_page_header_footer = True
builder.page_setup.odd_and_even_pages_header_footer = True
# Create the headers, then add three pages to the document to display each header type.
builder.write('Header for the first page')
builder.write('Header for even pages')
builder.write('Header for all other pages')
builder.writeln('Page3') + 'DocumentBuilder.HeadersAndFooters.docx')

Shows how to insert a Table of contents (TOC) into a document using heading styles as entries.

doc = aw.Document()
builder = aw.DocumentBuilder(doc)
# Insert a table of contents for the first page of the document.
# Configure the table to pick up paragraphs with headings of levels 1 to 3.
# Also, set its entries to be hyperlinks that will take us
# to the location of the heading when left-clicked in Microsoft Word.
builder.insert_table_of_contents('\\o "1-3" \\h \\z \\u')
# Populate the table of contents by adding paragraphs with heading styles.
# Each such heading with a level between 1 and 3 will create an entry in the table.
builder.paragraph_format.style_identifier = aw.StyleIdentifier.HEADING1
builder.writeln('Heading 1')
builder.paragraph_format.style_identifier = aw.StyleIdentifier.HEADING2
builder.writeln('Heading 1.1')
builder.writeln('Heading 1.2')
builder.paragraph_format.style_identifier = aw.StyleIdentifier.HEADING1
builder.writeln('Heading 2')
builder.writeln('Heading 3')
builder.paragraph_format.style_identifier = aw.StyleIdentifier.HEADING2
builder.writeln('Heading 3.1')
builder.paragraph_format.style_identifier = aw.StyleIdentifier.HEADING3
builder.writeln('Heading 3.1.1')
builder.writeln('Heading 3.1.2')
builder.writeln('Heading 3.1.3')
builder.paragraph_format.style_identifier = aw.StyleIdentifier.HEADING4
builder.paragraph_format.style_identifier = aw.StyleIdentifier.HEADING2
builder.writeln('Heading 3.2')
builder.writeln('Heading 3.3')
# A table of contents is a field of a type that needs to be updated to show an up-to-date result.
doc.update_fields() + 'DocumentBuilder.InsertToc.docx')

Shows how to apply and revert page setup settings to sections in a document.

doc = aw.Document()
builder = aw.DocumentBuilder(doc)
# Modify the page setup properties for the builder's current section and add text.
builder.page_setup.orientation = aw.Orientation.LANDSCAPE
builder.page_setup.vertical_alignment = aw.PageVerticalAlignment.CENTER
builder.writeln('This is the first section, which landscape oriented with vertically centered text.')
# If we start a new section using a document builder,
# it will inherit the builder's current page setup properties.
self.assertEqual(aw.Orientation.LANDSCAPE, doc.sections[1].page_setup.orientation)
self.assertEqual(aw.PageVerticalAlignment.CENTER, doc.sections[1].page_setup.vertical_alignment)
# We can revert its page setup properties to their default values using the "ClearFormatting" method.
self.assertEqual(aw.Orientation.PORTRAIT, doc.sections[1].page_setup.orientation)
self.assertEqual(aw.PageVerticalAlignment.TOP, doc.sections[1].page_setup.vertical_alignment)
builder.writeln('This is the second section, which is in default Letter paper size, portrait orientation and top alignment.') + 'PageSetup.ClearFormatting.docx')

See Also