danfickle / danfickle/openhtmltopdf
Problems with CSS position: relative in combination with -fs-table-paginate: paginate, since version 1.0.5
- Dominant language
- Java
- Stars
- 2.2k
- Forks
- 423
- PR merge metrics
- No merged PRs in 30d
Description
### Environment:
- Java 11 and 16
- OS Windows
- OpenHtmlToPdf version 1.0.5 - 1.0.9
- used markup: page features example (annotated example https://github.com/danfickle/openhtmltopdf/wiki/Page-features)
### Java Code:
```
final File outputFile = new File(TEMP, "compatibility.pdf");
final String sourceContent = new String(UnitTest.class.getResourceAsStream("/pdf/compatibility.html").readAllBytes());
Files.deleteIfExists(outputFile.toPath());
try (final OutputStream outputStream = new FileOutputStream(outputFile)) {
final PdfRendererBuilder builder = new PdfRendererBuilder();
builder.useFastMode();
builder.withHtmlContent(sourceContent, "/");
builder.toStream(outputStream);
builder.run();
}
```
### Problems
Please add the following examples to the style:
```
* {
position: relative;
}
```
```
java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 1
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
at java.base/java.util.Objects.checkIndex(Objects.java:372)
at java.base/java.util.ArrayList.get(ArrayList.java:459)
at com.openhtmltopdf.render.displaylist.PagedBoxCollector.getPageResult(PagedBoxCollector.java:927)
at com.openhtmltopdf.render.displaylist.PagedBoxCollector.collectInline(PagedBoxCollector.java:288)
at com.openhtmltopdf.render.displaylist.PagedBoxCollector.collect(PagedBoxCollector.java:271)
at com.openhtmltopdf.render.displaylist.DisplayListCollector.collect(DisplayListCollector.java:150)
at com.openhtmltopdf.render.displaylist.DisplayListCollector.collectLayers(DisplayListCollector.java:38)
at com.openhtmltopdf.render.displaylist.DisplayListCollector.collect(DisplayListCollector.java:169)
at com.openhtmltopdf.render.displaylist.DisplayListCollector.collectRoot(DisplayListCollector.java:88)
at com.openhtmltopdf.pdfboxout.PdfBoxRenderer.writePDFFast(PdfBoxRenderer.java:607)
at com.openhtmltopdf.pdfboxout.PdfBoxRenderer.createPdfFast(PdfBoxRenderer.java:554)
at com.openhtmltopdf.pdfboxout.PdfBoxRenderer.createPDF(PdfBoxRenderer.java:480)
at com.openhtmltopdf.pdfboxout.PdfBoxRenderer.createPDF(PdfBoxRenderer.java:417)
at com.openhtmltopdf.pdfboxout.PdfBoxRenderer.createPDF(PdfBoxRenderer.java:399)
at com.openhtmltopdf.pdfboxout.PdfRendererBuilder.run(PdfRendererBuilder.java:46)
at com.seanox.pdf.UnitTest.checkCompatibility(UnitTest.java:267)
```
---
```
th {
position: relative;
}
```
Loses the initial header on page 13.
---
```
thead, tbody, tfoot {
position: relative;
}
```
Loses the continued header and footer on page 14.
----
```
thead {
position: relative;
}
```
Loses the initial header on page 13.
This is different from the example previously.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by running the compatibility.html example through the Java code in UnitTest.checkCompatibility and inspect PagedBoxCollector.getPageResult, where the reported exception occurs. Compare output for the position: relative cases and verify that PDF generation completes with the initial, continued, and footer table headers preserved on the affected pages.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- css, java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 32/100