Silly Admin Trick: Avoid Tables going across Page Break

When doing PDF’s in Salesforce.com one thing that can be tricky is dynamic content caught between the page break. Signature block being a good example of something that you want kept together on the page. Using the CSS ‘page-break-inside’ can work 100% the first time or if you have a busy page with lots of formatting and CSS you might run in to issues especially when using ‘renderas=pdf’ as your HTML and CSS are rendered on the backend and not using your latest/greatest browser. At least that was what I found when my CSS worked great in Chrome and IE but bombed when doing a download/renderas=PDF.

One solution I found that worked 100% is wrapping your table in question in an apex:outputpanel like so:

<apex:outputPanel layout=”block” style=”page-break-inside: avoid;”>

I would like to take credit for this but as usual this was a google find: https://developer.salesforce.com/forums/?id=906F0000000AjSfIAK

Leave a Reply

Your email address will not be published. Required fields are marked *