I have a pageblocktable that is being rendered as a pdf. The PDF is set as A4 landscape with small margins and page numbering in a style sheet. The problem is that rows in the pageblocktable span the page break, any text above and below is split on the line, making it difficult to read that line. The lines heights are content-dependent, so I cannot add some sort of padding at a set point to force the page breaks where I want them.
The problem as I interpret it is that pageblocktables are contiguous, if you display one on a normally rendered page it will be one big block without breaks. When you say to render as PDF it simply takes the visuals, puts them into a graphic format, then slices it into pieces that fit the page margins.
Is there anything I can do in the style sheet or the page code to get the engine to be aware of the page break?
my somewhat redacted page code:
<apex:page controller="MyCustomController" title="My List" renderAs="pdf">
<apex:stylesheet value="{!URLFOR($Resource.pdfresources)}"/>
<apex:form >
<apex:pageBlock title="My List" mode="Edit" >
<apex:pageBlockTable value="{!DataList}" var="data" width="100%" headerClass="tableHeader" cellPadding="2px">
columns here
Here's a screenshot, you can clearly see the bleed-over.
Best Answer
You can set page breaks via CSS, though you may have to change your page's structure to accomplish this. There is a good example on Developerforce that demonstrates this. It works as follows:
<apex:repeat>
or a similar constructIn your controller:
In your VF page:
page-break-after:always;
at the end of each pageThe number of elements that you can fit on a page will vary and require some experimentation to get right. Also note that working in Development Mode breaks the CSS as I found out the hard way.