2

I have an apex PDF page. There are five different tabpanels to show records. Now when number of records increases the last record of last panel in a page gets segregated to the next page. In such cases I need to repeat the last tab panel of previous page along with it's headers in next one and then show the truncated record in next page. Can someone suggest a way out here?

Apex Page:

Incident Details for DMs/RMs

Page of

        <apex:outputField style="margin-left:-10px;width:200px;" value="{!Incident__c.Name}"/>
        <apex:outputField style="margin-left:-10px;width:200px;" value="{!Incident__c.Rep_Lookup_id__c}"/>
        <apex:outputField style="margin-left:-10px;width:200px;" value="{!Incident__c.Report_Publish_date__c}"/>
        <apex:outputField style="margin-left:-10px;width:200px;" value="{!Incident__c.Status_abv__c}"/>
        <apex:outputField style="margin-left:-10px;width:200px;" value="{!Incident__c.No_Of_Transactions_abv__c}"/>                                                
    </apex:pageBlockSection>
    </apex:form>
</apex:pageBlock>    
<apex:pageBlock title="Incident Transactions">
    <!--<apex:tabPanel switchType="client">-->

        <!--<apex:tab label="HCP Calls">
        <a href="http://www.tutorialspoint.com" target="_blank">Tutorials Point</a>
        <!--<a href="http://www.tutorialspoint.com" target="_blank">Tutorials Point</a>
        <a href="http://www.tutorialspoint.com" target="_self">Tutorials Point</a>--!-->


       <!-- <apex:tab label="Samples">
        <a href="http://www.tutorialspoint.com" target="_self">Tutorials Point</a>
        </apex:tab>
        <apex:tab label="Speaker Program Attendees">

        </apex:tab>
        <apex:tab label="Synch Rate">

        </apex:tab>                               
    </apex:tabPanel>-->

   <apex:outputPanel layout="none" rendered="{!IF(oIncTranListHCPDetail.size>0, true, false)}">
   <apex:tabPanel >
   <apex:tab label="HCP Calls" >

    <apex:pageBlockTable columns="9" value="{!oIncTranListHCPDetail}" border="true" var="itr" cellPadding="4" >

    <div class="page-break" >
<!-- Your content -->
    </div>
    <apex:column headerValue="Professional Name" style="background-color:#FFFFFF;" value="{!itr.Prof_First_Name_abv__c} {!itr.Prof_Middle_Name_abv__c} {!itr.Prof_Last_Name_abv__c}" />

     <!-- Need to put Profname string here from the map -->
    <apex:column headerValue=" ABS on Call" style="background-color:#FFFFFF;"/>
    <apex:column value="{!itr.Account_Abs_abv__c}" style="background-color:#FFFFFF;"/> 
    <apex:column headerValue=" Professional Address" style="background-color:#FFFFFF;"/>
    <apex:column value="{!itr.Prof_Address_Line1_abv__c}" style="background-color:#FFFFFF;"/> 
    <apex:column headerValue=" Associated Prescriber" value="{!itr.Associated_Prescriber_ID_abv__c}" style="background-color:#FFFFFF;"/>
    <apex:column headerValue=" Product" value="{!itr.Account_Abs_abv__c}" style="background-color:#FFFFFF;"/>
    <apex:column headerValue=" Activity Date" value="{!itr.Account_Abs_abv__c}" style="background-color:#FFFFFF;"/> 
    <apex:column headerValue=" Outcome - LOV" value="{!itr.Outcome_abv__c}" style="background-color:#FFFFFF;"/>



    </apex:pageBlockTable>
    </apex:tab>
    </apex:tabPanel>
    </apex:outputPanel>  


    <apex:outputPanel layout="none" rendered="{!IF(oIncTranListHCPSamples.size>0, true, false)}">
    <apex:tabPanel >
    <apex:tab label="Samples" >
    <apex:pageBlockTable columns="10" value="{!oIncTranListHCPSamples }" border="true" var="itr" cellPadding="4" >
    <apex:column headerValue="Sample Type" style="background-color:#FFFFFF;"  value="{!itr.Prof_First_Name_abv__c}" />
    <apex:column headerValue="Professional Name" style="background-color:#FFFFFF;" value="{!itr.Prof_First_Name_abv__c} {!itr.Prof_Middle_Name_abv__c}  {!itr.Prof_Last_Name_abv__c}" />
    <apex:column headerValue="ABS on Call" style="background-color:#FFFFFF;" value="{!itr.Account_Abs_abv__c}" />
    <apex:column headerValue="Professional Address" style="background-color:#FFFFFF;" value="{!itr.Prof_Address_Line1_abv__c}" />
    <apex:column headerValue="Product" style="background-color:#FFFFFF;" value="{!itr.Prof_First_Name_abv__c}" />
    <apex:column headerValue="Activity Date" style="background-color:#FFFFFF;" value="{!itr.Prof_First_Name_abv__c}" />
    <apex:column headerValue="Quantity (for hand samples, ESR, and DTP/BRC tied to rep)" style="background-color:#FFFFFF;" value="{!itr.Prof_First_Name_abv__c}" />
    <apex:column headerValue="Outcome - LOV" style="background-color:#FFFFFF;" value="{!itr.Outcome_abv__c}" />

    </apex:pageBlockTable>
    </apex:tab>
    </apex:tabPanel>
    </apex:outputPanel>


    <apex:outputPanel layout="none" rendered="{!IF(oIncTranListHCPSpeaker.size>0, true, false)}">
    <apex:tabPanel >
    <apex:tab label="Speaker Program Attendees" >

     <apex:pageBlockTable columns="9" value="{!oIncTranListHCPSpeaker }" border="true" var="itr" cellPadding="4" >
    <apex:column headerValue="Professional Name" style="background-color:#FFFFFF;" value="{!itr.Prof_First_Name_abv__c} {!itr.Prof_Middle_Name_abv__c}  {!itr.Prof_Last_Name_abv__c}" />
    <apex:column headerValue="ABS on Call" style="background-color:#FFFFFF;" value="{!itr.Account_Abs_abv__c}" />
    <apex:column headerValue="Professional Address" style="background-color:#FFFFFF;" value="{!itr.Prof_Address_Line1_abv__c}" />
    <apex:column headerValue="Product" style="background-color:#FFFFFF;" value="{!itr.Prof_First_Name_abv__c}" />
    <apex:column headerValue="Activity Date" style="background-color:#FFFFFF;" value="{!itr.Prof_First_Name_abv__c}" />
    <apex:column headerValue="Program Name, Date and Location" style="background-color:#FFFFFF;" value="{!itr.Prof_First_Name_abv__c}" />
    <apex:column headerValue="Outcome - LOV" style="background-color:#FFFFFF;" value="{!itr.Outcome_abv__c}" />

    </apex:pageBlockTable>
    </apex:tab>
    </apex:tabPanel>
    </apex:outputPanel>

    <apex:outputPanel layout="none" rendered="{!IF(oIncTranListSynch.size>0, true, false)}">
    <apex:tabPanel >
    <apex:tab label="Synch report">

     <apex:pageBlockTable columns="6" value="{!oIncTranListSynch}" border="true" var="itr" cellPadding="4" >
    <apex:column headerValue="Date of Previous Synchronization" style="background-color:#FFFFFF;" value="{!itr.Date_of_Prev_Sync_abv__c}" />
    <apex:column headerValue="Date of Last Synchronization" style="background-color:#FFFFFF;" value="{!itr.Date_of_Last_Sync_abv__c}" />
    <apex:column headerValue="Days between Synchronization" style="background-color:#FFFFFF;" value="{!itr.Days_bwn_Sync_abv__c}" />
    <apex:column headerValue="Outcome - LOV" style="background-color:#FFFFFF;" value="{!itr.Outcome_abv__c}" />

    </apex:pageBlockTable>
    </apex:tab>
    </apex:tabPanel>
    </apex:outputPanel>

    <apex:outputPanel layout="none" rendered="{!IF(oIncTranListHCI.size>0, true, false)}">
    <apex:tabPanel >
    <apex:tab label="HCI/HCO Calls" >

     <apex:pageBlockTable columns="10" value="{!oIncTranListHCI}" border="true" var="itr" cellPadding="4" >
    <apex:column headerValue="Account Name" style="background-color:#FFFFFF;" value="{!itr.Account_Name_abv__c}" />
    <apex:column headerValue="ABS on Call" style="background-color:#FFFFFF;" value="{!itr.Account_Abs_abv__c}" />
    <apex:column headerValue="Account Address" style="background-color:#FFFFFF;" value="{!itr.Account_Location_abv__c}" />
    <apex:column headerValue="Attendee Name" style="background-color:#FFFFFF;" value="{!itr.Prof_First_Name_abv__c}" />
    <apex:column headerValue="Attendee Role" style="background-color:#FFFFFF;" value="{!itr.Attendee_Role_abv__c}" />
    <apex:column headerValue="Detail" style="background-color:#FFFFFF;" value="{!itr.Prof_First_Name_abv__c}" />
    <apex:column headerValue="Activity Date" style="background-color:#FFFFFF;" value="{!itr.Prof_First_Name_abv__c}" />
    <apex:column headerValue="Outcome - LOV" style="background-color:#FFFFFF;" value="{!itr.Outcome_abv__c}" />

    </apex:pageBlockTable>
    </apex:tab>
    </apex:tabPanel>
    </apex:outputPanel>


    <apex:outputPanel layout="none" rendered="{!IF(oIncTranListPharmacy.size>0, true, false)}">
    <apex:tabPanel >
    <apex:tab label="Pharmacy Calls" >

     <apex:pageBlockTable columns="10" value="{!oIncTranListPharmacy}" border="true" var="itr" cellPadding="4" >
     <div class="page-break" >
<!-- Your content -->
     </div>
    <apex:column headerValue="Account Name" style="background-color:#FFFFFF;" value="{!itr.Account_Name_abv__c}" />
    <apex:column headerValue="ABS on Call" style="background-color:#FFFFFF;" value="{!itr.Account_Abs_abv__c}" />
    <apex:column headerValue="Account Address" style="background-color:#FFFFFF;" value="{!itr.Account_Location_abv__c}" />
    <apex:column headerValue="Attendee Name" style="background-color:#FFFFFF;" value="{!itr.Prof_First_Name_abv__c}" />
    <apex:column headerValue="Attendee Role" style="background-color:#FFFFFF;" value="{!itr.Attendee_Role_abv__c}" />
    <apex:column headerValue="Detail" style="background-color:#FFFFFF;" value="{!itr.Prof_First_Name_abv__c}" />
    <apex:column headerValue="Activity Date" style="background-color:#FFFFFF;" value="{!itr.Prof_First_Name_abv__c}" />
    <apex:column headerValue="Outcome - LOV" style="background-color:#FFFFFF;" value="{!itr.Outcome_abv__c}" />

    </apex:pageBlockTable>

    </apex:tab>
    </apex:tabPanel>
    </apex:outputPanel>

</apex:pageBlock>  

5

Referencing this CSS from an included stylesheet (or otherwise making sure that the definition stays in the <head></head> section of the page):

table {
    -fs-table-paginate: paginate;
}

puts a header at the start of each new page where a table crosses a page boundary. You can run this test case to see it working:

<apex:page standardController="Contact" recordSetVar="cs" renderAs="PDF" >

<apex:stylesheet value="{!$Resource.PdfCss}"/>

<table>
    <thead>
        <tr><th>Name</th></tr>
    </thead>
    <tbody>
        <apex:repeat value="{!cs}" var="c">
        <tr><td>{!c.Name}</td></tr>
        </apex:repeat>
        <!-- Easy way to get more than one page of rows with default controller -->
        <apex:repeat value="{!cs}" var="c">
        <tr><td>{!c.Name}</td></tr>
        </apex:repeat>
        <apex:repeat value="{!cs}" var="c">
        <tr><td>{!c.Name}</td></tr>
        </apex:repeat>
        <apex:repeat value="{!cs}" var="c">
        <tr><td>{!c.Name}</td></tr>
        </apex:repeat>
        <apex:repeat value="{!cs}" var="c">
        </apex:repeat>
    </tbody>
</table>

</apex:page>

Note that this is a feature of the present implementation - "fs" is presumably short for Flying Saucer - and is not AFAIK documented by Salesforce.

PS You may get lucky and create working PDF output using apex:pageBlockTable. But Salesforce lists that tag as one of the "Components That Are Unsafe to Use in a PDF" in Best Practices for Rendering PDFs so a safer approach is to use an apex:repeat tab and HTML markup for the PDF case. (Develop the page using renderAs="HTML" so you can debug the HTML output and then switch to renderAs="PDF" at the end.)

  • Keith C -- you need to write the definitive guide on PDF styling of VF pages :-) I find such styling issues to be one of the most frustrating things I've ever had to do with SFDC. – cropredy Nov 23 '14 at 2:08
  • @crop1645 Yeah it would have been helpful if Salesforce had documented the CSS available in the underlying implementation code... – Keith C Nov 23 '14 at 11:09
  • Thanks Keith! But I have an apex page with Apex block table approach. Can you please let me know the needful for my page? Please it updated in the question – Testing_SFDC Nov 24 '14 at 8:59
  • @SFDC_GEEK As an apex:pageBlockTable just emits a HTML table the CSS I posted is still appropriate. But see the PS I added to the answer. – Keith C Nov 24 '14 at 9:06
  • Keith! I am new to salesforce and can't get your words. Can you please do the implementation here for me? where should I put the table section , in CSS file that I have used? – Testing_SFDC Nov 24 '14 at 9:18

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.