Skip to content

Commit

Permalink
#202 #399 Failing test for table with too high first body row. [ci skip]
Browse files Browse the repository at this point in the history
Plus orphaned thead.

Also compiler fixes for ContentLimit/ContentLimitContainer.

Test based on the one provided by @jesselong. Thanks.
  • Loading branch information
danfickle committed Nov 23, 2019
1 parent 26116a6 commit 0cf6160
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public void updateBottom(int bottom) {
}
}

@Override
public String toString() {
return "[top=" + _top + ", bottom=" + _bottom + "]";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
public class ContentLimitContainer {
private ContentLimitContainer _parent;

private int _initialPageNo;
private List _contentLimits = new ArrayList();
private final int _initialPageNo;
private final List<ContentLimit> _contentLimits = new ArrayList<>();

private PageBox _lastPage;

Expand Down Expand Up @@ -57,7 +57,7 @@ private ContentLimit getContentLimit(int pageNo, boolean addAsNeeded) {

int target = pageNo - _initialPageNo;
if (target >= 0 && target < _contentLimits.size()) {
return (ContentLimit)_contentLimits.get(pageNo - _initialPageNo);
return _contentLimits.get(pageNo - _initialPageNo);
} else {
return null;
}
Expand Down Expand Up @@ -125,6 +125,7 @@ public boolean isContainsMultiplePages() {
return _contentLimits.size() > 1;
}

@Override
public String toString() {
return "[initialPageNo=" + _initialPageNo + ", limits=" + _contentLimits + "]";
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<html>
<head>
<style>
@page {
size: 200px 200px;
}
body {
border: 1px solid orange;
}
table {
-fs-table-paginate: paginate;
}
th {
background-color: red;
}
td {
background-color: blue;
}
th, td {
border: 1px solid black;
}
</style>
</head>
<body>
<div style="height: 70px;"></div>

<table>
<thead>
<tr><th>HA</th><th>HB</th></tr>
</thead>
<tbody>
<tr><td>a</td><td>b</td></tr>
<tr><td>c</td><td>d</td></tr>
</tbody>
</table>

</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,17 @@ public void testIssue399TableHeaderFooterWithNoRows() throws IOException {
assertTrue(vt.runTest("issue-399-table-header-with-no-rows"));
}

/**
* Tests that a paginated table pushed to the next page does not have too
* much height in the first body row and the thead section is not orphaned on
* the first page.
* https://github.com/danfickle/openhtmltopdf/issues/202
*/
@Test
@Ignore // First td has too much height, thead is orphaned on first page.
public void testIssue202PaginatedTableAtStartOfNewPage() throws IOException {
assertTrue(vt.runTest("issue-202-paginated-table-start-page"));
}

// TODO:
// + Elements that appear just on generated overflow pages.
Expand Down

0 comments on commit 0cf6160

Please sign in to comment.