public class LineNumberRestartMode
Example:
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");
Field Summary | ||
---|---|---|
static final int | RESTART_PAGE | |
Line numbering restarts at the start of every page.
|
||
static final int | RESTART_SECTION | |
Line numbering restarts at the section start.
|
||
static final int | CONTINUOUS | |
Line numbering continuous from the previous section.
|
public static final int RESTART_PAGE
public static final int RESTART_SECTION
public static final int CONTINUOUS