This is an archived forum post. The information may be outdated. Contact us if you have any questions.

Avoid breaking images

zhumar wrote on 2014-08-14:
I have a procedurally generated HTML view getting converted to PDF using the pdfcrowd API for PHP. The HTML contains tabular data. The first cell contains a small image that acts as a grade for that particular row. Currently, the generator will break the grade image if it needs to apply a page break. Is there something I can do to tell the API to basically allow X lines in a cell before allowing a page break inside the table?

I do NOT want to avoid page breaks inside of the table rows altogether. This can lead to large empty spaces in the PDF since some rows can be exceptionally longer than others.

What I would really like is to tell the API something like this:

cell 1 - OK to break below image
cell 2 - OK to break below title
cell 3 - OK to break after 4 lines of text
cell 4 - OK to break after 4 lines of text

I think I can manipulate the HTML to achieve this, but if there is an easier way through the API, please let me know.
support wrote on 2014-08-15:
Hello,

> What I would really like is to tell the API something like this:
> cell 1 - OK to break below image
> cell 2 - OK to break below title
> cell 3 - OK to break after 4 lines of text
> cell 4 - OK to break after 4 lines of text


Unfortunately, there is no support for anything like that in the API. The only thing that could help is to use the following css to avoid page breaks inside images.
img { page-break-inside: avoid; }