I need help with rendering a VF page as PDF. The VF page iterates over a list of account records using the repeat tag. I want to apply a page break for each element in the repeat tag. The code below is working, but it has an issue - it shows an empty PDF page after the last element. How can I avoid displaying an empty PDF page after the 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>
Thank you for your assistance.
Best regards,
Naveen