Class SectionStart

  • java.lang.Object
    • com.aspose.words.SectionStart
public class SectionStart 
extends java.lang.Object

Utility class containing constants. The type of break at the beginning of the section.


Shows how to specify how the section starts, from a new page, on the same page or other.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Add text to the first section and that comes with a blank document,
// then add a new section that starts a new page and give it text as well
builder.writeln("This text is in section 1.");
builder.writeln("This text is in section 2.");

// Section break types determine how a new section gets split from the previous section
// By inserting a "SectionBreakNewPage" type section break, we've set this section's SectionStart value to "NewPage" 
Assert.assertEquals(SectionStart.NEW_PAGE, doc.getSections().get(1).getPageSetup().getSectionStart());

// Insert a new column section the same way
builder.writeln("This text is in section 3.");

Assert.assertEquals(SectionStart.NEW_COLUMN, doc.getSections().get(2).getPageSetup().getSectionStart());

// We can change the types of section breaks by assigning different values to each section's SectionStart
// Setting their values to "Continuous" will put no visible breaks between sections
// and will leave all the content of this document on one page
doc.getSections().get(2).getPageSetup().setSectionStart(SectionStart.CONTINUOUS); + "PageSetup.SetSectionStart.docx");


Shows how to construct an Aspose Words document node by node.
Document doc = new Document();

// A newly created blank document still comes one section, one body and one paragraph
// Calling this method will remove all those nodes to completely empty the document

// This document now has no composite nodes that content can be added to
// If we wish to edit it, we will need to repopulate its node collection,
// which we will start to do with by creating a new Section node
Section section = new Section(doc);

// Append the section to the document

// Lets set some properties for the section

// The section that we created is empty, lets populate it. The section needs at least the Body node
Body body = new Body(doc);

// The body needs to have at least one paragraph
// Note that the paragraph has not yet been added to the document, 
// but we have to specify the parent document
// The parent document is needed so the paragraph can correctly work
// with styles and other document-wide information
Paragraph para = new Paragraph(doc);

// We can set some formatting for the paragraph
para.getParagraphFormat().setStyleName("Heading 1");

// So far we have one empty paragraph in the document
// The document is valid and can be saved, but lets add some text before saving
// Create a new run of text and add it to our paragraph
Run run = new Run(doc);
run.setText("Hello World!");

Assert.assertEquals("Hello World!" + ControlChar.SECTION_BREAK_CHAR, doc.getText()); + "Section.CreateFromScratch.docx");

Field Summary
static final intCONTINUOUS = 0
The new section starts on the same page as the previous section.
static final intNEW_COLUMN = 1
The section starts from a new column.
static final intNEW_PAGE = 2
The section starts from a new page.
static final intEVEN_PAGE = 3
The section starts on a new even page.
static final intODD_PAGE = 4
The section starts on a new odd page.

    • Field Detail

      • CONTINUOUS = 0

        public static final int CONTINUOUS
        The new section starts on the same page as the previous section.
      • NEW_COLUMN = 1

        public static final int NEW_COLUMN
        The section starts from a new column.
      • NEW_PAGE = 2

        public static final int NEW_PAGE
        The section starts from a new page.
      • EVEN_PAGE = 3

        public static final int EVEN_PAGE
        The section starts on a new even page.
      • ODD_PAGE = 4

        public static final int ODD_PAGE
        The section starts on a new odd page.