0

I've created a list button to generate CV for multiple selected records on list view. What should I do to have separate pdfs in one tab ?

So for example when I select 3 contacts I would like to have 3 pdfs for each contact. Now when I select 3 contacts I have one pdf.

This is my VF code:

<apex:page standardController="Contact" recordSetVar="contacts" extensions="GenerateResourceCv" renderAs="pdf">
<!-- <apex:form -->
<table cellpadding="4" cellspacing="0" width="100%" class="noBorder">
    <tr class="noBorder">
        <td class="heading noBorder" width="50%"><h2>Resource CV</h2></td>
    </tr>
</table>

<h2 class="objectLabel">Contact Detail</h2>

<table cellpadding="4" cellspacing="0" width="100%" border="1">
    <tr><td style="font-weight:bold;font-size:16px;" colspan="4">Contact Detail</td></tr>
    <apex:repeat value="{!contacts}" var="contact">
        <tr>
            <td class="dataLabel" width="20%">Name</td>
            <td class="dataValue" width="100%">{!contact.Name}</td>
        <tr>
            <td class="dataLabel" width="20%">Phone</td>
            <td class="dataValue" width="100%">{!contact.Phone}</td>
        </tr>
        <tr>
            <td class="dataLabel" width="20%">Email</td>
            <td class="dataValue" width="100%">{!contact.Email}</td>
        </tr>
        <tr>
            <td class="dataLabel" width="20%">Address</td>
            <td class="dataValue" width="100%">
                {!contact.MailingStreet}
                {!contact.MailingCity}<br/>
                {!contact.MailingState}<br/>
                {!contact.MailingPostalCode}<br/>
                {!contact.MailingCountry}
            </td>
        </tr>
        </tr>
    </apex:repeat>
</table>
<!-- </apex:form>-->

</apex:page>

Controller:

public class GenerateResourceCv {
ApexPages.StandardSetController setCon;
public final Contact contact;

public GenerateResourceCv(ApexPages.StandardSetController controller){
    setCon = controller;
    Set<Id> contactIdSet = new Set<Id>();

    for (Contact contact :(Contact[])setCon.getSelected()){
        contactIdSet.add(contact.Id);
    }
}
public Contact getContact(){
    return contact;
}

}

1 Answer 1

0

In order to generate X number of PDF's using VisualForces' RenderAs directive you'll need to load that VisualForce page X times.

This might be a good use case for the upcoming Salesforce Functions as you could queue X function runs to generate 1 pdf each.

You can also look at the possibility of generating a PDF and saving it into a ContentDocument which you can provide a link to.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .