public class TabAlignment
extends java.lang.Object
Examples:
Shows how to set custom tab stops for a paragraph.
Document doc = new Document();
Paragraph para = doc.getFirstSection().getBody().getFirstParagraph();
// If we are in a paragraph with no tab stops in this collection,
// the cursor will jump 36 points each time we press the Tab key in Microsoft Word.
Assert.assertEquals(0, doc.getFirstSection().getBody().getFirstParagraph().getEffectiveTabStops().length);
// We can add custom tab stops in Microsoft Word if we enable the ruler via the "View" tab.
// Each unit on this ruler is two default tab stops, which is 72 points.
// We can add custom tab stops programmatically like this.
TabStopCollection tabStops = doc.getFirstSection().getBody().getFirstParagraph().getParagraphFormat().getTabStops();
tabStops.add(72.0, TabAlignment.LEFT, TabLeader.DOTS);
tabStops.add(216.0, TabAlignment.CENTER, TabLeader.DASHES);
tabStops.add(360.0, TabAlignment.RIGHT, TabLeader.LINE);
// We can see these tab stops in Microsoft Word by enabling the ruler via "View" -> "Show" -> "Ruler".
Assert.assertEquals(3, para.getEffectiveTabStops().length);
// Any tab characters we add will make use of the tab stops on the ruler and may,
// depending on the tab leader's value, leave a line between the tab departure and arrival destinations.
para.appendChild(new Run(doc, "\tTab 1\tTab 2\tTab 3"));
doc.save(getArtifactsDir() + "Paragraph.TabStops.docx");
| Modifier and Type | Field and Description |
|---|---|
static int |
BAR
Draws a vertical bar at the tab stop position.
|
static int |
CENTER
Centers the text around the tab stop.
|
static int |
CLEAR
Clears any tab stop in this position.
|
static int |
DECIMAL
Aligns the text at the decimal dot.
|
static int |
LEFT
Left-aligns the text after the tab stop.
|
static int |
length |
static int |
LIST
The tab is a delimiter between the number/bullet and text in a list item.
|
static int |
RIGHT
Right-aligns the text at the tab stop.
|
| Modifier and Type | Method and Description |
|---|---|
static int |
fromName(java.lang.String tabAlignmentName) |
static java.lang.String |
getName(int tabAlignment) |
static int[] |
getValues() |
static java.lang.String |
toString(int tabAlignment) |
public static int LEFT
public static int CENTER
public static int RIGHT
public static int DECIMAL
public static int BAR
public static int LIST
public static int CLEAR
public static int length