/** * This method removes borders that have the same color and overlap 100%. * The result is improved onscreen rendering of thin border lines by some PDF viewers. */ public void MergeOverlaidBorders() { for (int i = 0; i < tableData.Count; i++) { List <Cell> currentRow = tableData[i]; for (int j = 0; j < currentRow.Count; j++) { Cell currentCell = currentRow[j]; if (j < currentRow.Count - 1) { Cell cellAtRight = currentRow[j + 1]; if (cellAtRight.GetBorder(Border.LEFT) && currentCell.GetPenColor() == cellAtRight.GetPenColor() && currentCell.GetLineWidth() == cellAtRight.GetLineWidth() && (currentCell.GetColSpan() + j) < (currentRow.Count - 1)) { currentCell.SetBorder(Border.RIGHT, false); } } if (i < tableData.Count - 1) { List <Cell> nextRow = tableData[i + 1]; Cell cellBelow = nextRow[j]; if (cellBelow.GetBorder(Border.TOP) && currentCell.GetPenColor() == cellBelow.GetPenColor() && currentCell.GetLineWidth() == cellBelow.GetLineWidth()) { currentCell.SetBorder(Border.BOTTOM, false); } } } } }