@@ -65,8 +65,6 @@ This file is part of the iText (R) project.
65
65
import com .itextpdf .layout .property .UnitValue ;
66
66
import com .itextpdf .layout .property .VerticalAlignment ;
67
67
import com .itextpdf .layout .tagging .LayoutTaggingHelper ;
68
- import org .slf4j .Logger ;
69
- import org .slf4j .LoggerFactory ;
70
68
71
69
import java .util .ArrayDeque ;
72
70
import java .util .ArrayList ;
@@ -75,6 +73,8 @@ This file is part of the iText (R) project.
75
73
import java .util .HashMap ;
76
74
import java .util .List ;
77
75
import java .util .Map ;
76
+ import org .slf4j .Logger ;
77
+ import org .slf4j .LoggerFactory ;
78
78
79
79
/**
80
80
* This class represents the {@link IRenderer renderer} object for a {@link Table}
@@ -781,7 +781,7 @@ public LayoutResult layout(LayoutContext layoutContext) {
781
781
// And now, when we possess such knowledge, we are performing the second attempt, but we need to nullify results
782
782
// from the previous attempt
783
783
if (bordersHandler instanceof CollapsedTableBorders ) {
784
- ((CollapsedTableBorders )bordersHandler ).setBottomBorderCollapseWith (null );
784
+ ((CollapsedTableBorders ) bordersHandler ).setBottomBorderCollapseWith (null , null );
785
785
}
786
786
bordersHandler .collapseTableWithFooter (footerRenderer .bordersHandler , hasContent || 0 != childRenderers .size ());
787
787
@@ -1050,10 +1050,6 @@ public LayoutResult layout(LayoutContext layoutContext) {
1050
1050
}
1051
1051
}
1052
1052
} else {
1053
- // the bottom border should be processed and placed lately
1054
- if (0 != heights .size ()) {
1055
- heights .set (heights .size () - 1 , heights .get (heights .size () - 1 ) - bottomTableBorderWidth / 2 );
1056
- }
1057
1053
if (null == footerRenderer ) {
1058
1054
if (0 != childRenderers .size ()) {
1059
1055
bordersHandler .applyBottomTableBorder (occupiedArea .getBBox (), layoutBox , 0 == childRenderers .size (), false , true );
@@ -1460,7 +1456,7 @@ private void drawBorders(DrawContext drawContext, boolean hasHeader, boolean has
1460
1456
}
1461
1457
1462
1458
1463
- // process halves of the borders here
1459
+ // process halves of horizontal bounding borders
1464
1460
if (childRenderers .size () == 0 ) {
1465
1461
Border [] borders = bordersHandler .tableBoundingBorders ;
1466
1462
if (null != borders [0 ]) {
@@ -1492,56 +1488,72 @@ private void drawBorders(DrawContext drawContext, boolean hasHeader, boolean has
1492
1488
1493
1489
if (bordersHandler instanceof CollapsedTableBorders ) {
1494
1490
if (hasFooter ) {
1495
- ((CollapsedTableBorders ) bordersHandler ).setBottomBorderCollapseWith (footerRenderer .bordersHandler .getFirstHorizontalBorder ());
1491
+ ((CollapsedTableBorders ) bordersHandler ).setBottomBorderCollapseWith (
1492
+ footerRenderer .bordersHandler .getFirstHorizontalBorder (),
1493
+ ((CollapsedTableBorders ) footerRenderer .bordersHandler )
1494
+ .getVerticalBordersCrossingTopHorizontalBorder ());
1496
1495
} else if (isBottomTablePart ) {
1497
- ((CollapsedTableBorders ) bordersHandler ).setBottomBorderCollapseWith (null );
1496
+ ((CollapsedTableBorders ) bordersHandler ).setBottomBorderCollapseWith (null , null );
1498
1497
}
1499
1498
}
1500
1499
// we do not need to fix top border, because either this is header or the top border has been already written
1501
1500
float y1 = startY ;
1501
+
1502
+ float [] heightsArray = new float [heights .size ()];
1503
+ for (int j = 0 ; j < heights .size (); j ++) {
1504
+ heightsArray [j ] = heights .get (j );
1505
+ }
1506
+
1507
+ // draw vertical borders
1508
+ float x1 = startX ;
1509
+ for (int i = 0 ; i <= bordersHandler .getNumberOfColumns (); i ++) {
1510
+ bordersHandler .drawVerticalBorder (drawContext .getCanvas (),
1511
+ new TableBorderDescriptor (i , startY , x1 , heightsArray ));
1512
+ if (i < countedColumnWidth .length ) {
1513
+ x1 += countedColumnWidth [i ];
1514
+ }
1515
+ }
1516
+
1517
+ // draw horizontal borders
1518
+
1519
+ // draw top border
1502
1520
if (isFooterRendererOfLargeTable ) {
1503
- bordersHandler .drawHorizontalBorder (0 , startX , y1 , drawContext .getCanvas (), countedColumnWidth );
1521
+ bordersHandler .drawHorizontalBorder (drawContext .getCanvas (), new TableBorderDescriptor (0 , startX , y1 ,
1522
+ countedColumnWidth ));
1504
1523
}
1505
- if (0 != heights .size ()) {
1524
+ if (isTopTablePart ) {
1525
+ bordersHandler .drawHorizontalBorder (drawContext .getCanvas (), new TableBorderDescriptor (0 , startX , startY ,
1526
+ countedColumnWidth ));
1527
+ }
1528
+
1529
+ // draw inner borders
1530
+ if (!heights .isEmpty ()) {
1506
1531
y1 -= (float ) heights .get (0 );
1507
1532
}
1508
1533
for (int i = 1 ; i < heights .size (); i ++) {
1509
- bordersHandler .drawHorizontalBorder (i , startX , y1 , drawContext .getCanvas (), countedColumnWidth );
1534
+ bordersHandler .drawHorizontalBorder (drawContext .getCanvas (),
1535
+ new TableBorderDescriptor (i , startX , y1 , countedColumnWidth ));
1510
1536
if (i < heights .size ()) {
1511
1537
y1 -= (float ) heights .get (i );
1512
1538
}
1513
1539
}
1514
- if (!isBottomTablePart && isComplete ) {
1515
- bordersHandler .drawHorizontalBorder (heights .size (), startX , y1 , drawContext .getCanvas (), countedColumnWidth );
1516
- }
1517
1540
1518
- float x1 = startX ;
1519
- if (countedColumnWidth .length > 0 ) {
1520
- x1 += countedColumnWidth [0 ];
1521
- }
1522
- for (int i = 1 ; i < bordersHandler .getNumberOfColumns (); i ++) {
1523
- bordersHandler .drawVerticalBorder (i , startY , x1 , drawContext .getCanvas (), heights );
1524
- if (i < countedColumnWidth .length ) {
1525
- x1 += countedColumnWidth [i ];
1526
- }
1541
+ // draw bottom border
1542
+ // TODO DEVSIX-5867 Check hasFooter, so that two footers are not drawn
1543
+ if (!isBottomTablePart && isComplete ) {
1544
+ bordersHandler .drawHorizontalBorder (drawContext .getCanvas (),
1545
+ new TableBorderDescriptor (heights .size (), startX , y1 , countedColumnWidth ));
1527
1546
}
1528
1547
1529
- // Draw bounding borders. Vertical borders are the last to draw in order to collapse with header / footer
1530
- if (isTopTablePart ) {
1531
- bordersHandler .drawHorizontalBorder (0 , startX , startY , drawContext .getCanvas (), countedColumnWidth );
1532
- }
1533
1548
//!isLastRendererForModelElement is a check that this is a split render. This is the case with the splitting of
1534
1549
// one cell when part of the cell moves to the next page. Therefore, if such a splitting occurs, a bottom border
1535
1550
// should be drawn. However, this should not be done for empty renderers that are also created during splitting,
1536
1551
// but this splitting, if the table does not fit on the page and the next cell is added to the next page.
1537
1552
// In this case, this code should not be processed, since the border in the above code has already been drawn.
1538
1553
if (isBottomTablePart && (isComplete || (!isLastRendererForModelElement && !isEmptyTableRenderer ()))) {
1539
- bordersHandler .drawHorizontalBorder (heights .size (), startX , y1 , drawContext .getCanvas (), countedColumnWidth );
1554
+ bordersHandler .drawHorizontalBorder (drawContext .getCanvas (), new TableBorderDescriptor (
1555
+ heights .size (), startX , y1 , countedColumnWidth ));
1540
1556
}
1541
- // draw left
1542
- bordersHandler .drawVerticalBorder (0 , startY , startX , drawContext .getCanvas (), heights );
1543
- // draw right
1544
- bordersHandler .drawVerticalBorder (bordersHandler .getNumberOfColumns (), startY , x1 , drawContext .getCanvas (), heights );
1545
1557
1546
1558
if (isTagged ) {
1547
1559
drawContext .getCanvas ().closeTag ();
0 commit comments