public class SectionLayoutMode
Example: Example:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Enable pitching, and then use it to set the number of lines per page in this section.
// A large enough font size will push some lines down onto the next page to avoid overlapping characters.
builder.getPageSetup().setLayoutMode(SectionLayoutMode.LINE_GRID);
builder.getPageSetup().setLinesPerPage(15);
builder.getParagraphFormat().setSnapToGrid(true);
for (int i = 0; i < 30; i++)
builder.write("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ");
doc.save(getArtifactsDir() + "PageSetup.LinesPerPage.docx");
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Enable pitching, and then use it to set the number of characters per line in this section.
builder.getPageSetup().setLayoutMode(SectionLayoutMode.GRID);
builder.getPageSetup().setCharactersPerLine(10);
// The number of characters also depends on the size of the font.
doc.getStyles().get("Normal").getFont().setSize(20.0);
Assert.assertEquals(8, doc.getFirstSection().getPageSetup().getCharactersPerLine());
builder.writeln("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");
doc.save(getArtifactsDir() + "PageSetup.CharactersPerLine.docx");
Field Summary | ||
---|---|---|
static final int | DEFAULT | |
Specifies that no document grid shall be applied to the contents of the corresponding section in the document.
|
||
static final int | GRID | |
Specifies that the corresponding section shall have both the additional line pitch and character pitch
added to each line and character within it in order to maintain a specific number
of lines per page and characters per line.
Characters will not be automatically aligned with gridlines on typing.
|
||
static final int | LINE_GRID | |
Specifies that the corresponding section shall have additional line pitch added to each line within it
in order to maintain the specified number of lines per page.
|
||
static final int | SNAP_TO_CHARS | |
Specifies that the corresponding section shall have both the additional line pitch and character pitch
added to each line and character within it in order to maintain a specific number
of lines per page and characters per line.
Characters will be automatically aligned with gridlines on typing.
|
public static final int DEFAULT
public static final int GRID
public static final int LINE_GRID
public static final int SNAP_TO_CHARS