com.aspose.words

Class LineNumberRestartMode

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

Utility class containing constants. Determines when automatic line numbering restarts.

Example:

Shows how to enable Microsoft Word line numbering for a section.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Line numbering for each section can be configured via PageSetup
PageSetup pageSetup = builder.getPageSetup();
pageSetup.setLineStartingNumber(1);
pageSetup.setLineNumberCountBy(3);
pageSetup.setLineNumberRestartMode(LineNumberRestartMode.RESTART_PAGE);
pageSetup.setLineNumberDistanceFromText(50.0d);

// LineNumberCountBy is set to 3, so every line that's a multiple of 3
// will display that line number to the left of the text
for (int i = 1; i <= 25; i++)
    builder.writeln(MessageFormat.format("Line {0}.", i));

// The line counter will skip any paragraph with this flag set to true
// Normally, the number "15" would normally appear next to this paragraph, which says "Line 15"
// Since we set this flag to true and this paragraph is not counted by numbering,
// number 15 will appear next to the next paragraph, "Line 16", and from then on counting will carry on as normal
// until it will restart according to LineNumberRestartMode
doc.getFirstSection().getBody().getParagraphs().get(14).getParagraphFormat().setSuppressLineNumbers(true);

doc.save(getArtifactsDir() + "PageSetup.LineNumbers.docx");
See Also:
PageSetup, PageSetup.LineNumberRestartMode

Field Summary
static final intRESTART_PAGE = 0
Line numbering restarts at the start of every page.
static final intRESTART_SECTION = 1
Line numbering restarts at the section start.
static final intCONTINUOUS = 2
Line numbering continuous from the previous section.
 

    • Field Detail

      • RESTART_PAGE = 0

        public static final int RESTART_PAGE
        Line numbering restarts at the start of every page.
      • RESTART_SECTION = 1

        public static final int RESTART_SECTION
        Line numbering restarts at the section start.
      • CONTINUOUS = 2

        public static final int CONTINUOUS
        Line numbering continuous from the previous section.