You need to sign in to do that
Don't have an account?

How to apply page break after each element in repeat in visualforce when rendering as pdf
Hi All,
I'm trying to render a VF page as pdf. The Vf page will iterate over a list account records with repeat tag.
For each element in repeat tag I want apply a page break. The below code working but is has a issue. The below code showing empty pdf after last element. How to avoid showing empty pdf page after last page.
Thanks in advance.
Regards,
Naveen.
I'm trying to render a VF page as pdf. The Vf page will iterate over a list account records with repeat tag.
For each element in repeat tag I want apply a page break. The below code working but is has a issue. The below code showing empty pdf after last element. How to avoid showing empty pdf page after last page.
<apex:page standardController="Account" recordSetVar="accnts" sidebar="false" renderAs="pdf"> <apex:pageBlock title="My Content" > <apex:repeat value="{!accnts}" var="acc" rows="3" first="5" > <div style="page-break-after:always"> <apex:outputText style="color: #f60; font-weight: bold;font-size:30px;" value="{!acc.Name}" > </apex:outputText> </div> </apex:repeat> </apex:pageBlock> </apex:page>
Thanks in advance.
Regards,
Naveen.
All Answers
To use page break after each element in repeat tag you may use something like CSS to break the page in PDF In order to avoid showing empty pdf page after the last page, You can use some CSS hack like if this is your last page then use` display:none css` in this` p tag`
Hope this helps.
Please mark this as solved if the information helps.
Thanks,
Nagendra
Finally with few changes from above worked