Reputation: 71
i have an html file and i'm using Itext 2 with flying Saucer to convert it to a pdf file.
The problem is that if an image starts near the page end, flying saucer render a portion of it it the end of the current page and the rest in the beginning of the next page.
How to say that i want the entire image on one page only?
Upvotes: 4
Views: 4583
Reputation: 31
There appears to be a bug in FlyingSaucer that is causing issues with page-break-inside: avoid.
The issue manifests when css: orphans kicks in, when a paragraph is laid out towards the end of a page and the minimum number of lines cannot be rendered on the page. Then the block box layout state machine appears to go wrong.
We have pushed a fix to a fork here: https://github.com/krokiet/flyingsaucer/tree/master
At some point we will raise a pull request to get this merged back into the main code base.
Upvotes: 2
Reputation: 5070
You can add this to your print css:
img {
page-break-inside: avoid;
}
The user guide (PDF) mentions it.
Upvotes: 5
Reputation: 143
I have the same problem but
img {page-break-inside: avoid;}
is not the final solution. Yes it has impact for result and in some situations it works but not always. Here is some more details about the same or similar problem. Similar problem
Upvotes: 1