java.lang.Object
com.aspose.words.BreakType
public class BreakType
- extends java.lang.Object
Utility class containing constants.
Specifies type of a break inside a document.
Example:
Shows how to insert sections using DocumentBuilder, specify page setup for a section and reset page setup to defaults.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Modify the first section in the document
builder.getPageSetup().setOrientation(Orientation.LANDSCAPE);
builder.getPageSetup().setVerticalAlignment(PageVerticalAlignment.CENTER);
builder.writeln("Section 1, landscape oriented and text vertically centered.");
// Start a new section and reset its formatting to defaults
builder.insertBreak(BreakType.SECTION_BREAK_NEW_PAGE);
builder.getPageSetup().clearFormatting();
builder.writeln("Section 2, back to default Letter paper size, portrait orientation and top alignment.");
doc.save(getArtifactsDir() + "PageSetup.ClearFormatting.docx");
Example:
Shows how to create headers and footers in a document using DocumentBuilder.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Specify that we want headers and footers different for first, even and odd pages
builder.getPageSetup().setDifferentFirstPageHeaderFooter(true);
builder.getPageSetup().setOddAndEvenPagesHeaderFooter(true);
// Create the headers
builder.moveToHeaderFooter(HeaderFooterType.HEADER_FIRST);
builder.write("Header for the first page");
builder.moveToHeaderFooter(HeaderFooterType.HEADER_EVEN);
builder.write("Header for even pages");
builder.moveToHeaderFooter(HeaderFooterType.HEADER_PRIMARY);
builder.write("Header for all other pages");
// Create three pages in the document
builder.moveToSection(0);
builder.writeln("Page1");
builder.insertBreak(BreakType.PAGE_BREAK);
builder.writeln("Page2");
builder.insertBreak(BreakType.PAGE_BREAK);
builder.writeln("Page3");
doc.save(getArtifactsDir() + "DocumentBuilder.HeadersAndFooters.docx");
Example:
Shows how to insert a Table of contents (TOC) into a document using heading styles as entries.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert a table of contents at the beginning of the document,
// and set it to pick up paragraphs with headings of levels 1 to 3 and entries to act like hyperlinks
builder.insertTableOfContents("\\o \"1-3\" \\h \\z \\u");
// Start the actual document content on the second page
builder.insertBreak(BreakType.PAGE_BREAK);
// Build a document with complex structure by applying different heading styles thus creating TOC entries
// The heading levels we use below will affect the list levels in which these items will appear in the TOC,
// and only levels 1-3 will be picked up by our TOC due to its settings
builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_1);
builder.writeln("Heading 1");
builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_2);
builder.writeln("Heading 1.1");
builder.writeln("Heading 1.2");
builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_1);
builder.writeln("Heading 2");
builder.writeln("Heading 3");
builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_2);
builder.writeln("Heading 3.1");
builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_3);
builder.writeln("Heading 3.1.1");
builder.writeln("Heading 3.1.2");
builder.writeln("Heading 3.1.3");
builder.getParagraphFormat().setStyleIdentifier(StyleIdentifier.HEADING_2);
builder.writeln("Heading 3.2");
builder.writeln("Heading 3.3");
// Call the method below to update the TOC and save
doc.updateFields();
doc.save(getArtifactsDir() + "DocumentBuilder.InsertToc.docx");
PARAGRAPH_BREAK = 0 | |
public static final int PARAGRAPH_BREAK |
-
Break between paragraphs.
PAGE_BREAK = 1 | |
public static final int PAGE_BREAK |
-
Explicit page break.
COLUMN_BREAK = 2 | |
public static final int COLUMN_BREAK |
-
Explicit column break.
SECTION_BREAK_CONTINUOUS = 3 | |
public static final int SECTION_BREAK_CONTINUOUS |
-
Specifies start of new section on the same page as the previous section.
SECTION_BREAK_NEW_COLUMN = 4 | |
public static final int SECTION_BREAK_NEW_COLUMN |
-
Specifies start of new section in the new column.
SECTION_BREAK_NEW_PAGE = 5 | |
public static final int SECTION_BREAK_NEW_PAGE |
-
Specifies start of new section on a new page.
SECTION_BREAK_EVEN_PAGE = 6 | |
public static final int SECTION_BREAK_EVEN_PAGE |
-
Specifies start of new section on a new even page.
SECTION_BREAK_ODD_PAGE = 7 | |
public static final int SECTION_BREAK_ODD_PAGE |
-
Specifies start of new section on a odd page.
LINE_BREAK = 8 | |
public static final int LINE_BREAK |
-
Explicit line break.
See Also:
Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
Aspose.Words Support Forum - our preferred method of support.