Knp_snappy page break in generated PDF file

I am working on a Symfony2 project to create a PDF from an HTML view. Below is config.yml

knp_snappy: pdf: enabled: true binary: /path/to/my/wkhtmltopdf options: no-stop-slow-scripts: ~ enable-javascript: ~ use-xserver: ~ page-size: A4 dpi: 300 

Now I want to know if the DIV overlaps at the edges of the page, if so add a page break before the DIV. It is currently displayed as follows.

enter image description here

I tried to get the height of the DIV and compare it with the height of the page, but that didn't work.

Is there any solution to find out when the DIV overlaps or the page automatically breaks when something overlaps?

+5
source share
1 answer

Try adding the "page-break-inside" style to your div:

 <div style="page-break-inside: avoid;"> ... content ... </div> 

wkhtmltopdf uses the webkit engine. This fact allows you to use styles to control the appearance of your PDF.

+8
source

Source: https://habr.com/ru/post/1233233/


All Articles