Alexey
Alexey

Reputation: 2478

Flying saucer: rowspan and page-break-inside

I'm using flying saucer to convert html page to PDF. There're two huge columns that are rowspanned over whole section of the table. All columns have

table td {
    border: 1px solid black;
    page-break-inside: avoid;
    vertical-align: middle;
}

style applied. So for every other column this works fine and they are correctly truncated. While rowspanned columns don't stop at the same height on each page (see screenshot)

enter image description here

Any suggestions how that can be fixed?

Upvotes: 2

Views: 1195

Answers (1)

Daniels118
Daniels118

Reputation: 1227

A possible workaround could be to not use the rowspan at all, but instead hide the borders for the cells in the third column. So:

  • remove the rowspan from the cell;
  • include a <td></td> even for the cells that should be grouped;
  • add the following styles:

``

tr:nth-child(n+5) td:nth-child(n+3) {
    border-top: none;
}

tr:not(:last-child) td:nth-child(n+3) {
    border-bottom: none;
}

In the first statement the n+5 means start hiding borders from the 5st row, so only the first 4 rows will keep the border. You may think of other kind of selectors if you get more confortable with.

Note: I don't know if the above rules work for flying-saucer, they work at least in Chrome print window, which is basically a html to pdf converter. Just try it.

Upvotes: 1

Related Questions