danfickle / danfickle/openhtmltopdf

Bug on repeating table header when using page-break-after: avoid; inside table

Open
#457 2 comments 0 reactions 1 assignee Claimed by @danfickle View on GitHub
Dominant language
Java
Stars
2.2k
Forks
423
PR merge metrics
No merged PRs in 30d

Description

Hello,

I found an issue when using page-break-after: avoid; in a table:

I have a use case where I need to keep together two elements.
I created two reproducers to illustrate better the issue:

Source:
[category_children_on_different_page.txt](https://github.com/danfickle/openhtmltopdf/files/4320381/category_children_on_different_page.txt)

Produces:
[category_children_on_different_page.pdf](https://github.com/danfickle/openhtmltopdf/files/4320384/category_children_on_different_page.pdf)

![category_children_on_different_page](https://user-images.githubusercontent.com/7378267/76457186-1161ab80-63b7-11ea-9220-906370dda8d7.png)

The problem here is the text "CATEGORY" is on page1, but his children started on page2. I would like to keep then together. So, I put this code: (just added page-break-after: avoid; on tbody)
```


CATEGORY

```

Indeed, CATEGORY now is together with its children, BUT the repeating header is gone:

Source:
[category_together_with_children_but_bug_on_repeating_header.txt](https://github.com/danfickle/openhtmltopdf/files/4320401/category_together_with_children_but_bug_on_repeating_header.txt)

Produces:
[category_together_with_children_but_bug_on_repeating_header.pdf](https://github.com/danfickle/openhtmltopdf/files/4320403/category_together_with_children_but_bug_on_repeating_header.pdf)

![category_together_with_children_but_bug_on_repeating_header](https://user-images.githubusercontent.com/7378267/76457209-1c1c4080-63b7-11ea-9161-ddcaf8b33a40.png)

All the contents are dynamic, so I don't know in advance how big will be itens or subitens. So far the only way I could achieve the desired output was using "page-break-after: avoid;".
I tried using widows / orphans, but I guess it does not work on tables.

Thanks for this great library. Hope you can continue this great work.

Best wishes,
lagar84.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.