MPDF keep 2 lines together
In using the PHP PDF generation library MDPF I ran into a limitation which I have to get past. First I ran into this:
Nullam sagittis varius ligula, at blandit tortor pharetra quis. Integer faucibus dui sed tortor fringilla a laoreet tellus sollicitudin. Sed dapibus, eros a dapibus lobortis, eros tellus volutpat massa, eget scelerisque mi lectus et neque. Praesent faucibus tempus nibh, ac tempus ante facilisis vitae. Proin risus diam, egestas id interdum et, consectetur eu sapien.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus rutrum cursus dolor, ut sollicitudin lacus faucibus at. Suspendisse potenti. Duis iaculis lacus et quam hendrerit vel scelerisque justo vestibulum. Fusce faucibus bibendum erat, vitae convallis elit blandit non. Aenean dignissim
--page break --
eleifend ac vitae nisl.
Which is considered a "widow." So I found that adding the CSS "page-break-inside: avoid;" carries the paragraph over if it doesn't fit. The above would become:
Nullam sagittis varius ligula, at blandit tortor pharetra quis. Integer faucibus dui sed tortor fringilla a laoreet tellus sollicitudin. Sed dapibus, eros a dapibus lobortis, eros tellus volutpat massa, eget scelerisque mi lectus et neque. Praesent faucibus tempus nibh, ac tempus ante facilisis vitae. Proin risus diam, egestas id interdum et, consectetur eu sapien.
--page break --
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus rutrum cursus dolor, ut sollicitudin lacus faucibus at. Suspendisse potenti. Duis iaculis lacus et quam hendrerit vel scelerisque justo vestibulum. Fusce faucibus bibendum erat, vitae convallis elit blandit non. Aenean dignissim e开发者_开发技巧leifend ac vitae nisl.
This is also a problem though because it would leave a lot of empty space sometimes at the bottom of a page. I need to be able to keep 2 lines together so that if it has to break the page before a paragraph ends, it keeps the last 2 lines together on the next page like so:
Nullam sagittis varius ligula, at blandit tortor pharetra quis. Integer faucibus dui sed tortor fringilla a laoreet tellus sollicitudin. Sed dapibus, eros a dapibus lobortis, eros tellus volutpat massa, eget scelerisque mi lectus et neque. Praesent faucibus tempus nibh, ac tempus ante facilisis vitae. Proin risus diam, egestas id interdum et, consectetur eu sapien.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus rutrum cursus dolor, ut sollicitudin lacus faucibus at. Suspendisse potenti. Duis iaculis lacus et quam hendrerit vel scelerisque
--page break --
justo vestibulum. Fusce faucibus bibendum erat, vitae convallis elit blandit non. Aenean dignissim eleifend ac vitae nisl.
Any idea how to get MPDF to do this? I know it's not built in but if anyone has any idea where I would even start adding this feature that would be helpful.
set autoPageBreak
$mpdf->autoPageBreak = false;
精彩评论