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
Brooks Johnson 6Brooks Johnson 6 

Batch Generate Visualforce PDF

Hi friends, I have three  VF pages that each uses the standard controller. The business case for these is to generate a custom report that exports in PDF.  I have a request for a to be able to generate multiple PDFs at one time. For example, the Region__c button would no longer generate a report for just that region but for every region (18 records)

What would be the best way to implement this? And is it possible using the Standard controller or will we need a custom controller?

The next step to this will be to generate reports on a related child record. All of a regions contacts etc... 

Below is a very truncated version of the page. 

<apex:page id="ProgramPerformanceRegion" showHeader="false" standardController="Region__c" docType="html-5.0"
           sideBar="false" standardStylesheets="false" applyBodyTag="false" applyHtmlTag="false" renderAs="advanced_pdf">
    <head>
        <title>Region Health Check Report</title>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1"/>
        <apex:stylesheet value="{!$Resource.HealthCheckStyle}"/>
    </head>   
    <table width="100%" class="main-text" cellpadding="0" cellspacing="0">
        <tr width="100%" class="main-text">
            <td width="50%" align="left" STYLE="font-size: 20px; font-weight: bold">Program Performance Scorecard</td>
        </tr>
        <tr width ="100%" class="main-text">
            <td width="50%" style="margin: 0">
                <span style="font-size: 18px">
                     <apex:outputText value="{!Region__c.Name}"/>
                </span>
            </td>

        </tr>
    </table>
    <apex:image url="{!$Resource.border_bar}" height="7"/>
    <div style="margin-bottom: 0; padding-bottom: 0">
        <p class="smallFont" style="margin-bottom: 0; padding-bottom: 0">
            The Program Performance Scorecard is a tool by which you can monitor the overall health of your region’s Influencer list.
            The factors that contribute to the overall health grade are listed below. Each category is worth 20% of the grade.
            Your grades are on page 2. This scorecard should be used in conjunction with the internal benchmarks and optimization guidelines to identify areas
            of opportunity and to inform your influencer program strategy.
        </p>
    </div>

    <table width="100%"    class="score_table smallFont" cellspacing="0">
        <tr width="100%"   class="darkBottomBorder smallFont">
            <th colspan="2"    class="darkBottomBorder smallFont" id="scoringConvention"> Scoring Convention </th>
            <th align="center" class="darkBottomBorder a_Color "> A</th>
            <th align="center" class="darkBottomBorder b_Color"> B</th>
            <th align="center" class="darkBottomBorder c_Color"> C</th>
            <th align="center" class="darkBottomBorder d_Color"> D</th>
            <th align="center" class="darkBottomBorder f_Color"> F</th>
        </tr>
        <tr width="15%" class="font smallFont">
            <td rowspan="8" width="15%" align="left" class="smallFont"> Each is worth 20% of overall grade</td>
        </tr>
        <tr class="bottom_border smallFont" width="100%" align="right">
            <td align="left" class="shaded bottom_border smallFont">List Growth Last<br/> 90 Days</td>
            <td align="center" class="bottom_border smallFont smallFont"> &#8805; 10 </td>
            <td  align="center" class="shaded bottom_border smallFont smallFont">  &#8805; 8</td>
            <td align="center" class="bottom_border smallFont smallFont">  &#8805; 4 </td>
            <td class="shaded bottom_border smallFont smallFont" align="center">  &#8805; 1 </td>
            <td align="center" class="bottom_border smallFont smallFont"> 0 </td>
        </tr>
        <tr class=" smallFont" width="100%" align="right">
            <td align="left" class="shaded bottom_border"> Percent Contacted</td>
            <td align="center" class="bottom_border smallFont">  &#8805; 50% </td>
            <td  align="center" class="shaded bottom_border smallFont">  &#8805; 35%</td>
            <td align="center" class="bottom_border smallFont">  &#8805; 20% </td>
            <td class="shaded bottom_border smallFont" align="center">  &#8805; 10%</td>
            <td align="center" class="bottom_border smallFont"> &#60; 10% </td>
        </tr>
        <tr class=" smallFont" width="100%" align="right">
            <td align="left" class="shaded bottom_border">Open Rate</td>
            <td align="center" class="bottom_border smallFont"> &#8805; 35% </td>
            <td  align="center" class="shaded bottom_border smallFont"> &#8805; 25%</td>
            <td align="center" class="bottom_border smallFont"> &#8805; 15% </td>
            <td class="shaded bottom_border smallFont" align="center"> &#8805; 7% </td>
            <td align="center" class="bottom_border smallFont"> &#60; 7% </td>
        </tr>
        <tr class=" smallFont" width="100%" align="right">
            <td align="left" class="shaded bottom_border">Click Through Rate</td>
            <td align="center" class="bottom_border smallFont"> &#8805; 20% </td>
            <td  align="center" class="shaded bottom_border smallFont"> &#8805; 10%</td>
            <td align="center" class="bottom_border smallFont">  &#8805; 5% </td>
            <td class="shaded bottom_border smallFont" align="center"> &#8805; 2% </td>
            <td align="center" class="bottom_border smallFont"> &#60; 2% </td>
        </tr>
        <tr class=" bottom_border smallFont" width="100%" align="right">
            <td align="left" class="shaded bottom_border">Unsubscribe Percentage</td>
            <td align="center" class="bottom_border smallFont"> &#60; 2%</td>
            <td  align="center" class="shaded bottom_border smallFont"> &#60; 4%</td>
            <td align="center" class="bottom_border smallFont"> &#60; 6% </td>
            <td class="shaded bottom_border smallFont" align="center"> &#60; 8% </td>
            <td align="center" class="bottom_border smallFont"> &#8805; 8% </td>
        </tr>

    </table>
    <!--    End of rubric section-->
    <!--    Start of Analysis Section-->
    <hr/>
    <span style="font-size: 12px; !important;">
        <apex:outputText escape="false" value=" {!Region__c.Analysis__c}"/>
    </span>

    <!--Start of Footer-->
    <div class="footer smallFont">

    </div>
    <div style="page-break-after: always"></div>
    <apex:image id="logo" url="{!$Resource.Comcast_Logo}" height="50px" width="50px"
               styleClass="img"/>
    <table width="100%" class="main-text" cellpadding="0" cellspacing="0" style="border-collapse: collapse">
        <tr width="100%" class="main-text font">
            <td width="50%" align="left" STYLE="font-size: 22px; font-weight: bold">Program Performance Scorecard</td>
            <td width="50%" align="right" STYLE="font-size: 14px">Overall Health Score</td>
        </tr>
        <tr width ="100%" class="main-text font">
            <td width="50%" style="margin: 0">
                <span style="font-size: 18px;">
                     <apex:outputText value="{!Region__c.Name}"/>
                </span>
            </td>
            <td  width="50%" align="right" style="margin-bottom: 0; padding-bottom: 0">
                     <apex:outputText value="{!Region__c.Grade__c}"
                                      style="font-size: 49px; font-weight: bold;
                                      padding-right: 60px;  font-family: Arial Unicode MS;
                                      padding-bottom: 0px; margin-bottom 0px;
                                     color: {!if(Region__c.Grade__c='A', '#00a846',
                                     if(Region__c.Grade__c='B', '#aabb1a',
                                     if(Region__c.Grade__c='C','#f0b428',
                                     if(Region__c.Grade__c='D', '#FF6428', '#B42846'))))}"/>
            </td>
        </tr>
    </table>
</apex:page>