IText 2 + Flying Saucer: how to avoid that the images appears broken between two pdf's pages?

痴心易碎 提交于 2019-12-11 08:47:20

问题


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?


回答1:


You can add this to your print css:

img {
  page-break-inside: avoid;
}

The user guide (PDF) mentions it.




回答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.




回答3:


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



来源:https://stackoverflow.com/questions/9499519/itext-2-flying-saucer-how-to-avoid-that-the-images-appears-broken-between-two

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!