com.aspose.words

Class BorderCollection

  • java.lang.Object
    • com.aspose.words.BorderCollection
  • All Implemented Interfaces:
    java.lang.Iterable
    public class BorderCollection 
    extends java.lang.Object

A collection of Border objects.
Different document elements have different borders. For example, ParagraphFormat has Bottom, Left, Right and Top borders. You can specify different formatting for each border independently or enumerate through all borders and apply same formatting.

Example:

Shows how to insert a paragraph with a top border.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Border topBorder = builder.getParagraphFormat().getBorders().getByBorderType(BorderType.TOP);
topBorder.setColor(Color.RED);
topBorder.setLineWidth(4.0d);
topBorder.setLineStyle(LineStyle.DASH_SMALL_GAP);

builder.writeln("Text with a red top border.");

doc.save(getArtifactsDir() + "Border.ParagraphTopBorder.docx");

Property Getters/Setters Summary
BordergetBottom()
Gets the bottom border.
java.awt.ColorgetColor()
void
setColor(java.awt.Colorvalue)
           Gets or sets the border color.
intgetCount()
Gets the number of borders in the collection.
doublegetDistanceFromText()
void
setDistanceFromText(doublevalue)
           Gets or sets distance of the border from text in points.
BordergetHorizontal()
Gets the horizontal border that is used between cells or conforming paragraphs.
BordergetLeft()
Gets the left border.
intgetLineStyle()
void
setLineStyle(intvalue)
           Gets or sets the border style. The value of the property is LineStyle integer constant.
doublegetLineWidth()
void
setLineWidth(doublevalue)
           Gets or sets the border width in points.
BordergetRight()
Gets the right border.
booleangetShadow()
void
setShadow(booleanvalue)
           Gets or sets a value indicating whether the border has a shadow.
BordergetTop()
Gets the top border.
BordergetVertical()
Gets the vertical border that is used between cells.
Borderget(int index)
Retrieves a Border object by index.
BordergetByBorderType(int borderType)
Retrieves a Border object by border type.
 
Method Summary
voidclearFormatting()
Removes all borders of an object.
booleanequals(BorderCollection brColl)
Compares collections of borders.
java.util.Iterator<Border>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()
        
        Gets the bottom border.

        Example:

        Shows how to apply border and shading color while building a table.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Start a table and set a default color/thickness for its borders.
        Table table = builder.startTable();
        table.setBorders(LineStyle.SINGLE, 2.0, Color.BLACK);
        
        // Create a row with two cells with different background colors.
        builder.insertCell();
        builder.getCellFormat().getShading().setBackgroundPatternColor(Color.RED);
        builder.writeln("Row 1, Cell 1.");
        builder.insertCell();
        builder.getCellFormat().getShading().setBackgroundPatternColor(Color.GREEN);
        builder.writeln("Row 1, Cell 2.");
        builder.endRow();
        
        // Reset cell formatting to disable the background colors
        // set a custom border thickness for all new cells created by the builder,
        // then build a second row.
        builder.getCellFormat().clearFormatting();
        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.insertCell();
        builder.writeln("Row 2, Cell 1.");
        builder.insertCell();
        builder.writeln("Row 2, Cell 2.");
        
        doc.save(getArtifactsDir() + "DocumentBuilder.TableBordersAndShading.docx");
      • getColor/setColor

        public java.awt.Color getColor() / public void setColor(java.awt.Color value)
        
        Gets or sets the border color.

        Returns the color of the first border in the collection.

        Sets the color of all borders in the collection excluding diagonal borders.

        Example:

        Shows how to create green wavy page border with a shadow.
        Document doc = new Document();
        PageSetup pageSetup = doc.getSections().get(0).getPageSetup();
        
        pageSetup.getBorders().setLineStyle(LineStyle.DOUBLE_WAVE);
        pageSetup.getBorders().setLineWidth(2.0);
        pageSetup.getBorders().setColor(Color.GREEN);
        pageSetup.getBorders().setDistanceFromText(24.0);
        pageSetup.getBorders().setShadow(true);
        
        doc.save(getArtifactsDir() + "PageSetup.PageBorders.docx");
      • getCount

        public int getCount()
        
        Gets the number of borders in the collection.

        Example:

        Shows how border collections can share elements.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        builder.writeln("Paragraph 1.");
        builder.write("Paragraph 2.");
        
        // Since we used the same border configuration while creating
        // these paragraphs, their border collections share the same elements.
        BorderCollection firstParagraphBorders = doc.getFirstSection().getBody().getFirstParagraph().getParagraphFormat().getBorders();
        BorderCollection secondParagraphBorders = builder.getCurrentParagraph().getParagraphFormat().getBorders();
        
        for (int i = 0; i < firstParagraphBorders.getCount(); i++) {
            Assert.assertTrue(firstParagraphBorders.get(i).equals(secondParagraphBorders.get(i)));
            Assert.assertEquals(firstParagraphBorders.get(i).hashCode(), secondParagraphBorders.get(i).hashCode());
            Assert.assertFalse(firstParagraphBorders.get(i).isVisible());
        }
        
        for (Border border : secondParagraphBorders)
            border.setLineStyle(LineStyle.DOT_DASH);
        
        // After changing the line style of the borders in just the second paragraph,
        // the border collections no longer share the same elements.
        for (int i = 0; i < firstParagraphBorders.getCount(); i++) {
            Assert.assertFalse(firstParagraphBorders.get(i).equals(secondParagraphBorders.get(i)));
            Assert.assertNotEquals(firstParagraphBorders.get(i).hashCode(), secondParagraphBorders.get(i).hashCode());
        
            // Changing the appearance of an empty border makes it visible.
            Assert.assertTrue(secondParagraphBorders.get(i).isVisible());
        }
        
        doc.save(getArtifactsDir() + "Border.SharedElements.docx");
      • getDistanceFromText/setDistanceFromText

        public double getDistanceFromText() / public void setDistanceFromText(double value)
        
        Gets or sets distance of the border from text in points.

        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:

        Shows how to create green wavy page border with a shadow.
        Document doc = new Document();
        PageSetup pageSetup = doc.getSections().get(0).getPageSetup();
        
        pageSetup.getBorders().setLineStyle(LineStyle.DOUBLE_WAVE);
        pageSetup.getBorders().setLineWidth(2.0);
        pageSetup.getBorders().setColor(Color.GREEN);
        pageSetup.getBorders().setDistanceFromText(24.0);
        pageSetup.getBorders().setShadow(true);
        
        doc.save(getArtifactsDir() + "PageSetup.PageBorders.docx");
      • getHorizontal

        public Border getHorizontal()
        
        Gets the horizontal border that is used between cells or conforming paragraphs.

        Example:

        Shows how to apply settings to horizontal borders to a paragraph's format.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Create a red horizontal border for the paragraph. Any paragraphs created afterwards will inherit these border settings.
        BorderCollection borders = doc.getFirstSection().getBody().getFirstParagraph().getParagraphFormat().getBorders();
        borders.getHorizontal().setColor(Color.RED);
        borders.getHorizontal().setLineStyle(LineStyle.DASH_SMALL_GAP);
        borders.getHorizontal().setLineWidth(3.0);
        
        // Write text to the document without creating a new paragraph afterward.
        // Since there is no paragraph underneath, the horizontal border will not be visible.
        builder.write("Paragraph above horizontal border.");
        
        // Once we add a second paragraph, the border of the first paragraph will become visible.
        builder.insertParagraph();
        builder.write("Paragraph below horizontal border.");
        
        doc.save(getArtifactsDir() + "Border.HorizontalBorders.docx");

        Example:

        Shows how to apply settings to vertical borders to a table row's format.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Create a table with red and blue inner borders.
        Table table = builder.startTable();
        
        for (int i = 0; i < 3; i++) {
            builder.insertCell();
            builder.write(MessageFormat.format("Row {0}, Column 1", i + 1));
            builder.insertCell();
            builder.write(MessageFormat.format("Row {0}, Column 2", i + 1));
        
            Row row = builder.endRow();
            BorderCollection borders = row.getRowFormat().getBorders();
        
            // Adjust the appearance of borders that will appear between rows.
            borders.getHorizontal().setColor(Color.RED);
            borders.getHorizontal().setLineStyle(LineStyle.DOT);
            borders.getHorizontal().setLineWidth(2.0d);
        
            // Adjust the appearance of borders that will appear between cells.
            borders.getVertical().setColor(Color.BLUE);
            borders.getVertical().setLineStyle(LineStyle.DOT);
            borders.getVertical().setLineWidth(2.0d);
        }
        
        // A row format, and a cell's inner paragraph use different border settings.
        Border border = table.getFirstRow().getFirstCell().getLastParagraph().getParagraphFormat().getBorders().getVertical();
        
        Assert.assertEquals(0, border.getColor().getRGB());
        Assert.assertEquals(0.0d, border.getLineWidth());
        Assert.assertEquals(LineStyle.NONE, border.getLineStyle());
        
        doc.save(getArtifactsDir() + "Border.VerticalBorders.docx");
      • getLeft

        public Border getLeft()
        
        Gets the left border.

        Example:

        Shows how to apply border and shading color while building a table.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Start a table and set a default color/thickness for its borders.
        Table table = builder.startTable();
        table.setBorders(LineStyle.SINGLE, 2.0, Color.BLACK);
        
        // Create a row with two cells with different background colors.
        builder.insertCell();
        builder.getCellFormat().getShading().setBackgroundPatternColor(Color.RED);
        builder.writeln("Row 1, Cell 1.");
        builder.insertCell();
        builder.getCellFormat().getShading().setBackgroundPatternColor(Color.GREEN);
        builder.writeln("Row 1, Cell 2.");
        builder.endRow();
        
        // Reset cell formatting to disable the background colors
        // set a custom border thickness for all new cells created by the builder,
        // then build a second row.
        builder.getCellFormat().clearFormatting();
        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.insertCell();
        builder.writeln("Row 2, Cell 1.");
        builder.insertCell();
        builder.writeln("Row 2, Cell 2.");
        
        doc.save(getArtifactsDir() + "DocumentBuilder.TableBordersAndShading.docx");
      • getLineStyle/setLineStyle

        public int getLineStyle() / public void setLineStyle(int value)
        
        Gets or sets the border style. The value of the property is LineStyle integer constant.

        Returns the style of the first border in the collection.

        Sets the style of all borders in the collection excluding diagonal borders.

        Example:

        Shows how to create green wavy page border with a shadow.
        Document doc = new Document();
        PageSetup pageSetup = doc.getSections().get(0).getPageSetup();
        
        pageSetup.getBorders().setLineStyle(LineStyle.DOUBLE_WAVE);
        pageSetup.getBorders().setLineWidth(2.0);
        pageSetup.getBorders().setColor(Color.GREEN);
        pageSetup.getBorders().setDistanceFromText(24.0);
        pageSetup.getBorders().setShadow(true);
        
        doc.save(getArtifactsDir() + "PageSetup.PageBorders.docx");
      • getLineWidth/setLineWidth

        public double getLineWidth() / public void setLineWidth(double value)
        
        Gets or sets the border width in points.

        Returns the width of the first border in the collection.

        Sets the width of all borders in the collection excluding diagonal borders.

        Example:

        Shows how to create green wavy page border with a shadow.
        Document doc = new Document();
        PageSetup pageSetup = doc.getSections().get(0).getPageSetup();
        
        pageSetup.getBorders().setLineStyle(LineStyle.DOUBLE_WAVE);
        pageSetup.getBorders().setLineWidth(2.0);
        pageSetup.getBorders().setColor(Color.GREEN);
        pageSetup.getBorders().setDistanceFromText(24.0);
        pageSetup.getBorders().setShadow(true);
        
        doc.save(getArtifactsDir() + "PageSetup.PageBorders.docx");
      • getRight

        public Border getRight()
        
        Gets the right border.

        Example:

        Shows how to apply border and shading color while building a table.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Start a table and set a default color/thickness for its borders.
        Table table = builder.startTable();
        table.setBorders(LineStyle.SINGLE, 2.0, Color.BLACK);
        
        // Create a row with two cells with different background colors.
        builder.insertCell();
        builder.getCellFormat().getShading().setBackgroundPatternColor(Color.RED);
        builder.writeln("Row 1, Cell 1.");
        builder.insertCell();
        builder.getCellFormat().getShading().setBackgroundPatternColor(Color.GREEN);
        builder.writeln("Row 1, Cell 2.");
        builder.endRow();
        
        // Reset cell formatting to disable the background colors
        // set a custom border thickness for all new cells created by the builder,
        // then build a second row.
        builder.getCellFormat().clearFormatting();
        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.insertCell();
        builder.writeln("Row 2, Cell 1.");
        builder.insertCell();
        builder.writeln("Row 2, Cell 2.");
        
        doc.save(getArtifactsDir() + "DocumentBuilder.TableBordersAndShading.docx");
      • getShadow/setShadow

        public boolean getShadow() / public void setShadow(boolean value)
        
        Gets or sets a value indicating whether the border has a shadow.

        Gets the value from the first border in the collection.

        Sets the value for all borders in the collection excluding diagonal borders.

        Example:

        Shows how to create green wavy page border with a shadow.
        Document doc = new Document();
        PageSetup pageSetup = doc.getSections().get(0).getPageSetup();
        
        pageSetup.getBorders().setLineStyle(LineStyle.DOUBLE_WAVE);
        pageSetup.getBorders().setLineWidth(2.0);
        pageSetup.getBorders().setColor(Color.GREEN);
        pageSetup.getBorders().setDistanceFromText(24.0);
        pageSetup.getBorders().setShadow(true);
        
        doc.save(getArtifactsDir() + "PageSetup.PageBorders.docx");
      • getTop

        public Border getTop()
        
        Gets the top border.

        Example:

        Shows how to apply border and shading color while building a table.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Start a table and set a default color/thickness for its borders.
        Table table = builder.startTable();
        table.setBorders(LineStyle.SINGLE, 2.0, Color.BLACK);
        
        // Create a row with two cells with different background colors.
        builder.insertCell();
        builder.getCellFormat().getShading().setBackgroundPatternColor(Color.RED);
        builder.writeln("Row 1, Cell 1.");
        builder.insertCell();
        builder.getCellFormat().getShading().setBackgroundPatternColor(Color.GREEN);
        builder.writeln("Row 1, Cell 2.");
        builder.endRow();
        
        // Reset cell formatting to disable the background colors
        // set a custom border thickness for all new cells created by the builder,
        // then build a second row.
        builder.getCellFormat().clearFormatting();
        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.insertCell();
        builder.writeln("Row 2, Cell 1.");
        builder.insertCell();
        builder.writeln("Row 2, Cell 2.");
        
        doc.save(getArtifactsDir() + "DocumentBuilder.TableBordersAndShading.docx");
      • getVertical

        public Border getVertical()
        
        Gets the vertical border that is used between cells.

        Example:

        Shows how to apply settings to vertical borders to a table row's format.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Create a table with red and blue inner borders.
        Table table = builder.startTable();
        
        for (int i = 0; i < 3; i++) {
            builder.insertCell();
            builder.write(MessageFormat.format("Row {0}, Column 1", i + 1));
            builder.insertCell();
            builder.write(MessageFormat.format("Row {0}, Column 2", i + 1));
        
            Row row = builder.endRow();
            BorderCollection borders = row.getRowFormat().getBorders();
        
            // Adjust the appearance of borders that will appear between rows.
            borders.getHorizontal().setColor(Color.RED);
            borders.getHorizontal().setLineStyle(LineStyle.DOT);
            borders.getHorizontal().setLineWidth(2.0d);
        
            // Adjust the appearance of borders that will appear between cells.
            borders.getVertical().setColor(Color.BLUE);
            borders.getVertical().setLineStyle(LineStyle.DOT);
            borders.getVertical().setLineWidth(2.0d);
        }
        
        // A row format, and a cell's inner paragraph use different border settings.
        Border border = table.getFirstRow().getFirstCell().getLastParagraph().getParagraphFormat().getBorders().getVertical();
        
        Assert.assertEquals(0, border.getColor().getRGB());
        Assert.assertEquals(0.0d, border.getLineWidth());
        Assert.assertEquals(LineStyle.NONE, border.getLineStyle());
        
        doc.save(getArtifactsDir() + "Border.VerticalBorders.docx");
      • get

        public Border get(int index)
        
        Retrieves a Border object by index.
        Parameters:
        index - Zero-based index of the border to retrieve.

        Example:

        Shows how border collections can share elements.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        builder.writeln("Paragraph 1.");
        builder.write("Paragraph 2.");
        
        // Since we used the same border configuration while creating
        // these paragraphs, their border collections share the same elements.
        BorderCollection firstParagraphBorders = doc.getFirstSection().getBody().getFirstParagraph().getParagraphFormat().getBorders();
        BorderCollection secondParagraphBorders = builder.getCurrentParagraph().getParagraphFormat().getBorders();
        
        for (int i = 0; i < firstParagraphBorders.getCount(); i++) {
            Assert.assertTrue(firstParagraphBorders.get(i).equals(secondParagraphBorders.get(i)));
            Assert.assertEquals(firstParagraphBorders.get(i).hashCode(), secondParagraphBorders.get(i).hashCode());
            Assert.assertFalse(firstParagraphBorders.get(i).isVisible());
        }
        
        for (Border border : secondParagraphBorders)
            border.setLineStyle(LineStyle.DOT_DASH);
        
        // After changing the line style of the borders in just the second paragraph,
        // the border collections no longer share the same elements.
        for (int i = 0; i < firstParagraphBorders.getCount(); i++) {
            Assert.assertFalse(firstParagraphBorders.get(i).equals(secondParagraphBorders.get(i)));
            Assert.assertNotEquals(firstParagraphBorders.get(i).hashCode(), secondParagraphBorders.get(i).hashCode());
        
            // Changing the appearance of an empty border makes it visible.
            Assert.assertTrue(secondParagraphBorders.get(i).isVisible());
        }
        
        doc.save(getArtifactsDir() + "Border.SharedElements.docx");
      • getByBorderType

        public Border getByBorderType(int borderType)
        
        Retrieves a Border object by border type.

        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.

        Parameters:
        borderType - A BorderType value. A BorderType value that specifies the type of the border to retrieve.

        Example:

        Shows how to decorate text with borders and shading.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        BorderCollection borders = builder.getParagraphFormat().getBorders();
        borders.setDistanceFromText(20.0);
        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);
        
        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("This paragraph is formatted with a double border and shading.");
        doc.save(getArtifactsDir() + "DocumentBuilder.ApplyBordersAndShading.docx");
    • Method Detail

      • clearFormatting

        public void clearFormatting()
        Removes all borders of an object.

        Example:

        Shows how to remove all borders from all paragraphs in a document.
        Document doc = new Document(getMyDir() + "Borders.docx");
        
        // The first paragraph of this document has visible borders with these settings.
        BorderCollection firstParagraphBorders = doc.getFirstSection().getBody().getFirstParagraph().getParagraphFormat().getBorders();
        
        Assert.assertEquals(Color.RED.getRGB(), firstParagraphBorders.getColor().getRGB());
        Assert.assertEquals(LineStyle.SINGLE, firstParagraphBorders.getLineStyle());
        Assert.assertEquals(3.0d, firstParagraphBorders.getLineWidth());
        
        // Use the "ClearFormatting" method on each paragraph to remove all borders.
        for (Paragraph paragraph : doc.getFirstSection().getBody().getParagraphs()) {
            paragraph.getParagraphFormat().getBorders().clearFormatting();
        
            for (Border border : paragraph.getParagraphFormat().getBorders()) {
                Assert.assertEquals(0, border.getColor().getRGB());
                Assert.assertEquals(LineStyle.NONE, border.getLineStyle());
                Assert.assertEquals(0.0d, border.getLineWidth());
            }
        }
        
        doc.save(getArtifactsDir() + "BorderCollection.RemoveAllBorders.docx");
      • equals

        public boolean equals(BorderCollection brColl)
                      throws java.lang.Exception
        Compares collections of borders.

        Example:

        Shows how border collections can share elements.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        builder.writeln("Paragraph 1.");
        builder.write("Paragraph 2.");
        
        // Since we used the same border configuration while creating
        // these paragraphs, their border collections share the same elements.
        BorderCollection firstParagraphBorders = doc.getFirstSection().getBody().getFirstParagraph().getParagraphFormat().getBorders();
        BorderCollection secondParagraphBorders = builder.getCurrentParagraph().getParagraphFormat().getBorders();
        
        for (int i = 0; i < firstParagraphBorders.getCount(); i++) {
            Assert.assertTrue(firstParagraphBorders.get(i).equals(secondParagraphBorders.get(i)));
            Assert.assertEquals(firstParagraphBorders.get(i).hashCode(), secondParagraphBorders.get(i).hashCode());
            Assert.assertFalse(firstParagraphBorders.get(i).isVisible());
        }
        
        for (Border border : secondParagraphBorders)
            border.setLineStyle(LineStyle.DOT_DASH);
        
        // After changing the line style of the borders in just the second paragraph,
        // the border collections no longer share the same elements.
        for (int i = 0; i < firstParagraphBorders.getCount(); i++) {
            Assert.assertFalse(firstParagraphBorders.get(i).equals(secondParagraphBorders.get(i)));
            Assert.assertNotEquals(firstParagraphBorders.get(i).hashCode(), secondParagraphBorders.get(i).hashCode());
        
            // Changing the appearance of an empty border makes it visible.
            Assert.assertTrue(secondParagraphBorders.get(i).isVisible());
        }
        
        doc.save(getArtifactsDir() + "Border.SharedElements.docx");
      • iterator

        public java.util.Iterator<Border> iterator()
        Returns an enumerator object that can be used to iterate over all borders in the collection.

        Example:

        Shows how to iterate over and edit all of the borders in a paragraph format object.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Configure the builder's paragraph format settings to create a green wave border on all sides.
        BorderCollection borders = builder.getParagraphFormat().getBorders();
        
        Iterator<Border> enumerator = borders.iterator();
        while (enumerator.hasNext()) {
            Border border = enumerator.next();
            border.setColor(Color.green);
            border.setLineStyle(LineStyle.WAVE);
            border.setLineWidth(3.0);
        }
        
        // Insert a paragraph. Our border settings will determine the appearance of its border.
        builder.writeln("Hello world!");
        
        doc.save(getArtifactsDir() + "BorderCollection.GetBordersEnumerator.docx");