java.lang.Objectcom.aspose.words.BorderCollection
public class BorderCollection
Example:
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 | ||
---|---|---|
Border | getBottom() | |
Gets the bottom border. | ||
java.awt.Color | getColor() | |
void | setColor(java.awt.Color value) | |
Gets or sets the border color. | ||
int | getCount() | |
Gets the number of borders in the collection. | ||
double | getDistanceFromText() | |
void | setDistanceFromText(double value) | |
Gets or sets distance of the border from text in points. | ||
Border | getHorizontal() | |
Gets the horizontal border that is used between cells or conforming paragraphs. | ||
Border | getLeft() | |
Gets the left border. | ||
int | getLineStyle() | |
void | setLineStyle(int value) | |
Gets or sets the border style. The value of the property is LineStyle integer constant. | ||
double | getLineWidth() | |
void | setLineWidth(double value) | |
Gets or sets the border width in points. | ||
Border | getRight() | |
Gets the right border. | ||
boolean | getShadow() | |
void | setShadow(boolean value) | |
Gets or sets a value indicating whether the border has a shadow. | ||
Border | getTop() | |
Gets the top border. | ||
Border | getVertical() | |
Gets the vertical border that is used between cells. | ||
Border | get(int index) | |
Retrieves a Border object by index. | ||
Border | getByBorderType(int borderType) | |
Retrieves a Border object by border type. |
Method Summary | ||
---|---|---|
void | clearFormatting() | |
Removes all borders of an object. | ||
java.util.Iterator | iterator() | |
Returns an enumerator object that can be used to iterate over all borders in the collection. |
Property Getters/Setters Detail |
---|
getBottom | |
public Border getBottom() |
Example:
Shows how to format table and cell with different borders and shadingsDocument doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); Table table = builder.startTable(); builder.insertCell(); // Set the borders for the entire table. table.setBorders(LineStyle.SINGLE, 2.0, Color.BLACK); // Set the cell shading for this cell. builder.getCellFormat().getShading().setBackgroundPatternColor(Color.RED); builder.writeln("Cell #1"); builder.insertCell(); // Specify a different cell shading for the second cell. builder.getCellFormat().getShading().setBackgroundPatternColor(Color.GREEN); builder.writeln("Cell #2"); // End this row. builder.endRow(); // Clear the cell formatting from previous operations. builder.getCellFormat().clearFormatting(); // Create the second row. builder.insertCell(); // Create larger borders for the first cell of this row. This will be different // compared to the borders set for the table. builder.getCellFormat().getBorders().getLeft().setLineWidth(4.0); builder.getCellFormat().getBorders().getRight().setLineWidth(4.0); builder.getCellFormat().getBorders().getTop().setLineWidth(4.0); builder.getCellFormat().getBorders().getBottom().setLineWidth(4.0); builder.writeln("Cell #3"); builder.insertCell(); // Clear the cell formatting from the previous cell. builder.getCellFormat().clearFormatting(); builder.writeln("Cell #4"); doc.save(getMyDir() + "Table.SetBordersAndShading Out.doc");
getColor/setColor | |
public java.awt.Color getColor() / public void setColor(java.awt.Color value) |
Returns the color of the first border in the collection.
Sets the color of all borders in the collection excluding diagonal borders.
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() + "PageSetup.PageBorders Out.doc");
getCount | |
public int getCount() |
getDistanceFromText/setDistanceFromText | |
public double getDistanceFromText() / public void setDistanceFromText(double value) |
Gets the distance from text for the first border.
Sets the distance from text for all borders in the collection excluding diagonal borders.
Has no effect and will be automatically reset to zero for borders of table cells.
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() + "PageSetup.PageBorders Out.doc");
getHorizontal | |
public Border getHorizontal() |
getLeft | |
public Border getLeft() |
Example:
Shows how to format table and cell with different borders and shadingsDocument doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); Table table = builder.startTable(); builder.insertCell(); // Set the borders for the entire table. table.setBorders(LineStyle.SINGLE, 2.0, Color.BLACK); // Set the cell shading for this cell. builder.getCellFormat().getShading().setBackgroundPatternColor(Color.RED); builder.writeln("Cell #1"); builder.insertCell(); // Specify a different cell shading for the second cell. builder.getCellFormat().getShading().setBackgroundPatternColor(Color.GREEN); builder.writeln("Cell #2"); // End this row. builder.endRow(); // Clear the cell formatting from previous operations. builder.getCellFormat().clearFormatting(); // Create the second row. builder.insertCell(); // Create larger borders for the first cell of this row. This will be different // compared to the borders set for the table. builder.getCellFormat().getBorders().getLeft().setLineWidth(4.0); builder.getCellFormat().getBorders().getRight().setLineWidth(4.0); builder.getCellFormat().getBorders().getTop().setLineWidth(4.0); builder.getCellFormat().getBorders().getBottom().setLineWidth(4.0); builder.writeln("Cell #3"); builder.insertCell(); // Clear the cell formatting from the previous cell. builder.getCellFormat().clearFormatting(); builder.writeln("Cell #4"); doc.save(getMyDir() + "Table.SetBordersAndShading Out.doc");
getLineStyle/setLineStyle | |
public int getLineStyle() / public void setLineStyle(int value) |
Returns the style of the first border in the collection.
Sets the style of all borders in the collection excluding diagonal borders.
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() + "PageSetup.PageBorders Out.doc");
getLineWidth/setLineWidth | |
public double getLineWidth() / public void setLineWidth(double value) |
Returns the width of the first border in the collection.
Sets the width of all borders in the collection excluding diagonal borders.
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() + "PageSetup.PageBorders Out.doc");
getRight | |
public Border getRight() |
Example:
Shows how to format table and cell with different borders and shadingsDocument doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); Table table = builder.startTable(); builder.insertCell(); // Set the borders for the entire table. table.setBorders(LineStyle.SINGLE, 2.0, Color.BLACK); // Set the cell shading for this cell. builder.getCellFormat().getShading().setBackgroundPatternColor(Color.RED); builder.writeln("Cell #1"); builder.insertCell(); // Specify a different cell shading for the second cell. builder.getCellFormat().getShading().setBackgroundPatternColor(Color.GREEN); builder.writeln("Cell #2"); // End this row. builder.endRow(); // Clear the cell formatting from previous operations. builder.getCellFormat().clearFormatting(); // Create the second row. builder.insertCell(); // Create larger borders for the first cell of this row. This will be different // compared to the borders set for the table. builder.getCellFormat().getBorders().getLeft().setLineWidth(4.0); builder.getCellFormat().getBorders().getRight().setLineWidth(4.0); builder.getCellFormat().getBorders().getTop().setLineWidth(4.0); builder.getCellFormat().getBorders().getBottom().setLineWidth(4.0); builder.writeln("Cell #3"); builder.insertCell(); // Clear the cell formatting from the previous cell. builder.getCellFormat().clearFormatting(); builder.writeln("Cell #4"); doc.save(getMyDir() + "Table.SetBordersAndShading Out.doc");
getShadow/setShadow | |
public boolean getShadow() / public void setShadow(boolean value) |
Gets the value from the first border in the collection.
Sets the value for all borders in the collection excluding diagonal borders.
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() + "PageSetup.PageBorders Out.doc");
getTop | |
public Border getTop() |
Example:
Shows how to format table and cell with different borders and shadingsDocument doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); Table table = builder.startTable(); builder.insertCell(); // Set the borders for the entire table. table.setBorders(LineStyle.SINGLE, 2.0, Color.BLACK); // Set the cell shading for this cell. builder.getCellFormat().getShading().setBackgroundPatternColor(Color.RED); builder.writeln("Cell #1"); builder.insertCell(); // Specify a different cell shading for the second cell. builder.getCellFormat().getShading().setBackgroundPatternColor(Color.GREEN); builder.writeln("Cell #2"); // End this row. builder.endRow(); // Clear the cell formatting from previous operations. builder.getCellFormat().clearFormatting(); // Create the second row. builder.insertCell(); // Create larger borders for the first cell of this row. This will be different // compared to the borders set for the table. builder.getCellFormat().getBorders().getLeft().setLineWidth(4.0); builder.getCellFormat().getBorders().getRight().setLineWidth(4.0); builder.getCellFormat().getBorders().getTop().setLineWidth(4.0); builder.getCellFormat().getBorders().getBottom().setLineWidth(4.0); builder.writeln("Cell #3"); builder.insertCell(); // Clear the cell formatting from the previous cell. builder.getCellFormat().clearFormatting(); builder.writeln("Cell #4"); doc.save(getMyDir() + "Table.SetBordersAndShading Out.doc");
getVertical | |
public Border getVertical() |
get | |
public Border get(int index) |
index
- Zero-based index of the border to retrieve.getByBorderType | |
public Border getByBorderType(int borderType) |
Note that not all borders are present for different document elements. This method throws an exception if you request a border not applicable to the current object.
borderType
- A Example:
Shows how to apply borders and shading to a paragraph.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Set paragraph borders BorderCollection borders = builder.getParagraphFormat().getBorders(); borders.setDistanceFromText(20); borders.getByBorderType(BorderType.LEFT).setLineStyle(LineStyle.DOUBLE); borders.getByBorderType(BorderType.RIGHT).setLineStyle(LineStyle.DOUBLE); borders.getByBorderType(BorderType.TOP).setLineStyle(LineStyle.DOUBLE); borders.getByBorderType(BorderType.BOTTOM).setLineStyle(LineStyle.DOUBLE); // Set paragraph shading Shading shading = builder.getParagraphFormat().getShading(); shading.setTexture(TextureIndex.TEXTURE_DIAGONAL_CROSS); shading.setBackgroundPatternColor(new Color(240, 128, 128)); // Light Coral shading.setForegroundPatternColor(new Color(255, 160, 122)); // Light Salmon builder.write("I'm a formatted paragraph with double border and nice shading.");
Method Detail |
---|
clearFormatting | |
public void clearFormatting() |
iterator | |
public java.util.Iterator iterator() |