3

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?

user1240273
  • 61
  • 1
  • 3

3 Answers3

4

You can add this to your print css:

img {
  page-break-inside: avoid;
}

The user guide (PDF) mentions it.

sbk
  • 3,856
  • 1
  • 19
  • 19
Adam
  • 5,045
  • 1
  • 25
  • 31
  • Adam - I noticed that you're one of the top posters for flying-saucer issues - I have created a chat room for iText/flying-saucer issues since I'm sick of posting questions on it - I'm wondering if you wouldn't mind taking a look at it - http://chat.stackoverflow.com/rooms/8945/itext – Zack Macomber Mar 16 '12 at 12:48
2

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.

Pylot
  • 31
  • 3
0

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

Community
  • 1
  • 1
user3333010
  • 113
  • 2
  • 9