public class Border
Borders can be applied to various document elements including paragraph, run of text inside a paragraph or a table cell.
Example:
Inserts a String surrounded by a border into a document.DocumentBuilder builder = new DocumentBuilder(); builder.getFont().getBorder().setColor(Color.GREEN); builder.getFont().getBorder().setLineWidth(2.5); builder.getFont().getBorder().setLineStyle(LineStyle.DASH_DOT_STROKER); builder.write("run of text in a green border");
Example:
Inserts a paragraph with a top border.DocumentBuilder builder = new DocumentBuilder(); Border topBorder = builder.getParagraphFormat().getBorders().getByBorderType(BorderType.TOP); topBorder.setColor(Color.RED); topBorder.setLineStyle(LineStyle.DASH_SMALL_GAP); topBorder.setLineWidth(4); builder.writeln("Hello World!");
Property Getters/Setters Summary | ||
---|---|---|
java.awt.Color | getColor() | |
void | setColor(java.awt.Colorvalue) | |
Gets or sets the border color. | ||
double | getDistanceFromText() | |
void | setDistanceFromText(doublevalue) | |
Gets or sets distance of the border from text or from the page edge in points. | ||
boolean | isVisible() | |
Returns true if the LineStyle is not LineStyle.None.
|
||
int | getLineStyle() | |
void | setLineStyle(intvalue) | |
Gets or sets the border style. The value of the property is LineStyle integer constant. | ||
double | getLineWidth() | |
void | setLineWidth(doublevalue) | |
Gets or sets the border width in points. | ||
boolean | getShadow() | |
void | setShadow(booleanvalue) | |
Gets or sets a value indicating whether the border has a shadow. |
Method Summary | ||
---|---|---|
void | clearFormatting() | |
Resets border properties to default values.
|
||
boolean | equals(java.lang.Object obj) | |
Determines whether the specified object is equal in value to the current object.
|
||
int | hashCode() | |
Serves as a hash function for this type.
|
public java.awt.Color getColor() / public void setColor(java.awt.Color value)
Example:
Inserts a String surrounded by a border into a document.DocumentBuilder builder = new DocumentBuilder(); builder.getFont().getBorder().setColor(Color.GREEN); builder.getFont().getBorder().setLineWidth(2.5); builder.getFont().getBorder().setLineStyle(LineStyle.DASH_DOT_STROKER); builder.write("run of text in a green border");
public double getDistanceFromText() / public void setDistanceFromText(double value)
Example:
Creates a page border that looks like a wide blue band at the top of the first page only.Document doc = new Document(); PageSetup ps = doc.getSections().get(0).getPageSetup(); ps.setBorderAlwaysInFront(false); ps.setBorderDistanceFrom(PageBorderDistanceFrom.PAGE_EDGE); ps.setBorderAppliesTo(PageBorderAppliesTo.FIRST_PAGE); Border border = ps.getBorders().getByBorderType(BorderType.TOP); border.setLineStyle(LineStyle.SINGLE); border.setLineWidth(30); border.setColor(Color.BLUE); border.setDistanceFromText(0); doc.save(getMyDir() + "\\Artifacts\\PageSetup.PageBorderTop.doc");
public boolean isVisible()
public int getLineStyle() / public void setLineStyle(int value)
If you set line style to none, then line width is automatically changed to zero.
Example:
Inserts a String surrounded by a border into a document.DocumentBuilder builder = new DocumentBuilder(); builder.getFont().getBorder().setColor(Color.GREEN); builder.getFont().getBorder().setLineWidth(2.5); builder.getFont().getBorder().setLineStyle(LineStyle.DASH_DOT_STROKER); builder.write("run of text in a green border");
public double getLineWidth() / public void setLineWidth(double value)
If you set line width greater than zero when line style is none, the line style is automatically changed to single line.
Example:
Inserts a String surrounded by a border into a document.DocumentBuilder builder = new DocumentBuilder(); builder.getFont().getBorder().setColor(Color.GREEN); builder.getFont().getBorder().setLineWidth(2.5); builder.getFont().getBorder().setLineStyle(LineStyle.DASH_DOT_STROKER); builder.write("run of text in a green border");
public boolean getShadow() / public void setShadow(boolean value)
In Microsoft Word, for a border to have a shadow, the borders on all four sides (left, top, right and bottom) should be of the same type, width, color and all should have the Shadow property set to true.
Example:
Creates a fancy looking green wavy page border with a shadow.Document doc = new Document(); PageSetup ps = doc.getSections().get(0).getPageSetup(); ps.getBorders().setLineStyle(LineStyle.DOUBLE_WAVE); ps.getBorders().setLineWidth(2); ps.getBorders().setColor(Color.GREEN); ps.getBorders().setDistanceFromText(24); ps.getBorders().setShadow(true); doc.save(getMyDir() + "\\Artifacts\\PageSetup.PageBorders.doc");
public void clearFormatting()
Example:
Shows how to remove borders from a paragraph one by one.Document doc = new Document(getMyDir() + "Border.Borders.doc"); DocumentBuilder builder = new DocumentBuilder(doc); BorderCollection borders = builder.getParagraphFormat().getBorders(); for (Border border : borders) { border.clearFormatting(); } builder.getCurrentParagraph().getRuns().get(0).setText("Paragraph with no border"); doc.save(getMyDir() + "\\Artifacts\\Border.NoBorder.doc");
public boolean equals(java.lang.Object obj)
public int hashCode()