1

I have the following VF page, but when I render it as pdf the Apex:repeat tables break in the middle to the next page. I'm thinking of limiting the tables displayed in each page to avoid table breaks. Is there any way of doing this or any better ideas ? Any help on this would be appreciated.

<!-- Report Data -->
        <apex:outputPanel layout="none" >
            <apex:repeat value="{!rsReportRows}" var="reportRow" >
                <!-- Risk Data -->
                <table cellpadding="7" style="border-top:1px solid black;border-left:1px solid black;border-right:1px solid black; border-bottom:1px solid black; width:100%;">
                    <tr>
                        <td style="text-align:center;" colspan="{!parentObj.fieldApiNamesList.size}" ><b>Risk</b></td>
                    </tr>
                    <tr>
                        <apex:repeat value="{!parentObj.fieldLabelsList}" var="fieldLabel" >
                            <th style="font-size:{!pdfFontSize}pt;" ><apex:outputText value="{!fieldLabel}" /></th>
                        </apex:repeat>
                    </tr>
                    <tr>
                        <apex:repeat value="{!parentObj.fieldApiNamesList}" var="field" >
                            <td >
                                <apex:outputField value="{!reportRow.risk[field]}" rendered="{!field != 'risk__residual_score_movement_direction__c'}" />
                                <apex:outputField value="{!reportRow.risk[field]}" rendered="{!field == 'risk__residual_score_movement_direction__c' && (CONTAINS(reportRow.risk[field],'Up') || CONTAINS(reportRow.risk[field],'Down') || CONTAINS(reportRow.risk[field],'Right'))}" />
                            </td>
                        </apex:repeat>
                    </tr>
                </table>

                <!-- Related List Data -->
                <apex:repeat value="{!relatedList}" var="rList" >
                    <apex:outputPanel layout="none" rendered="{!rList.isSelected && rList.fieldsList.fieldApiNamesList.size > 0}" >
                        <table cellpadding="7" style="border-bottom: 1px solid black;border-left:1px solid black;border-right:1px solid black; width:100%;">
                            <tr>
                                <td style="text-align:center;" colspan="{!rList.fieldsList.fieldApiNamesList.size}" ><b>{!rList.relationshipLabel}</b></td>
                            </tr>
                            <tr>
                                <apex:repeat value="{!rList.fieldsList.fieldLabelsList}" var="fieldLabel" >
                                    <th ><apex:outputText value="{!fieldLabel}" /></th>
                                </apex:repeat>
                            </tr>

                            <apex:repeat value="{!reportRow.objRecords[rList.relationshipName]}" var="record" >
                                <tr>
                                    <apex:repeat value="{!rList.fieldsList.fieldApiNamesList}" var="field" >
                                        <td>
                                            <apex:outputField value="{!record[field]}" />
                                        </td>
                                    </apex:repeat>
                                </tr>
                            </apex:repeat>
                        </table>
                    </apex:outputPanel>
                </apex:repeat>
                <div style="clear:both;">&nbsp;</div>
                <div style="clear:both;">&nbsp;</div>
            </apex:repeat>
        </apex:outputPanel>
  • 2
    You should be able to achieve that by using some CSS. Have a look at page-break-inside Property. Some more information on it can be found here – BarCotter Oct 31 '14 at 11:29
  • Thanks for the help! I'm still trying but no luck yet :( – Tinkerbell Oct 31 '14 at 12:28
2

page-break-after: always; fixed the issue. Could display one table at a page.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.