function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Robbert Bos2Robbert Bos2 

Pagebreaks in Pageblock(table)

I've made a résumé to render as a word document and I got a specific problem. I call the job history witth apex and show this in a visualforce table. Problem I have here is that this table gets shown on a new page and only on that page. So if the information is larger then one page, some of the data is not shown.

Does anybody know how to insert pagepreaks into the pageblock(table)?
 
APEX:

public class relatedCV {
        public mployee__MF_Recruitment_Candidate__c can;
        public relatedCV(ApexPages.StandardController sc) {
            this.can = (mployee__MF_Recruitment_Candidate__c)sc.getRecord();
        }

        public list<mployee__candidatePosition__c> getWorks(){
           return [SELECT Name, Id, mployee__companyName__c, mployee__title__c, mployee__summary__c, mployee__startDateYear__c, mployee__endDateYear__c, Werkzaamheden__c FROM mployee__candidatePosition__c WHERE mployee__Candidate__c =:can.id];
        }

        
    }
 
VF Page

<apex:page standardStylesheets="false" standardController="mployee__MF_Recruitment_Candidate__c" extensions="relatedCV" sidebar="false" contentType="application/msword#test.doc" cache="true">
<html xmlns:w="urn:schemas-microsoft-com:office:word">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<head>

<style>
p.MsoHeader, li.MsoHeader, div.MsoHeader    {
    margin:-0.1in 0in 0in -0.6in !important;
    padding:0in 0in 0in 0in !important;
    margin-top:0pt;
    mso-pagination:widow-orphan;
    tab-stops:center 3.0in right 6.0in;
    }
    
p.MsoFooter, li.MsoFooter, div.MsoFooter    {
    margin:0in 0in 0in 0in;
    margin-bottom:.0001pt;
    mso-pagination:widow-orphan;
    tab-stops:center 3.0in right 6.0in;
    font-family:DINPro-Light, Verdana, Arial;
    font-weight:normal;
    font-size:7.5pt;
    }
    
@page Section1    {
    size:8.5in 11.0in; 
    margin:0.5in 0.3in 0.5in 0.3in;
    mso-header-margin:0.0in;
    mso-header:h1;
    mso-footer:f1; 
    mso-footer-margin:0.3in;
    mso-paper-source:0;
    }
    
div.Section1    {
    page:Section1;
    }

table#hrdftrtbl{
    margin:0in 0in 0in 9in;
    }
     
p    {
    font-size:8.0pt;
    font-family:"Verdana",sans-serif;
    }
  
*    {
    font-family:"Verdana",sans-serif !important;
    }
    
.fontapex {
    font-family:"Verdana",sans-serif !important;
    }
 
table.header  {
    width:100%;
    border-collapse:collapse;
    border:none;
    }
  
td.headerTD    {
    border-top:solid #E5472A 1.0pt;
    border-left:none;
    border-bottom:solid #E5472A 1.0pt;
    border-right:none;
    padding:0cm 5.4pt 0cm 5.4pt;height:3.0pt;
    text-align:center;
    font-weight:bold;
    }
  </style>
</head>
    
<div class="Section1" style="page-break-after:always">

    <!--Werkervaring-->
    <table class="blok" width="100%">
        <tr>
            <td valign="top" class="HeaderTD">
                <p><i>Relevante werkervaring</i></p>
            </td>
        </tr>
    </table>
  
    <apex:pageBlock mode="maindetail" >
        <apex:pageBlockTable value="{!Works}" var="work" align="left" style="padding: 0px 0px 10px 20px;">
            <apex:column headerValue="" width="150" style="vertical-align:top;">
                <p>{!work.mployee__startDateYear__c} - {!work.mployee__endDateYear__c}</p>           
                
            </apex:column>
            <apex:column headerValue="">
                <p><b>{!work.mployee__companyName__c}</b><br/>
                <i>{!work.mployee__title__c}</i></p>
                <p>Werkzaamheden:<apex:outputText escape="false"><p class="fontapex">{!work.Werkzaamheden__c}</p></apex:outputText></p>
                <p>&nbsp;</p>

            </apex:column>
        </apex:pageBlockTable>
        <br/><p>&nbsp;</p><br/>
    </apex:pageBlock><!--Werkervaring-->

</div>

</html>
</apex:page>

 
Best Answer chosen by Robbert Bos2
SandhyaSandhya (Salesforce Developers) 
Hi, 

Try using 

<div style="page-break-before: always" />

Will move everything that appears after this DIV onto the next page.


There are also other similar page-break properties; you can see how they all work here.

https://css-tricks.com/almanac/properties/p/page-break/

If you need to have page breaks in the text that is displaying in an apex:pageblocktable. 

Then you can use something like this.

Try <apex:column><apex:outputText value="{!br}" escape="false" /></apex:column> in your VF page.

Hope this helps you!

If this helps you please mark it as BestAnswer so that it will make available for others as a proper solution.

Thanks and Regards
Sandhya