2

I have a table that shows 10 record and whenever i click on 'create PDF' button..whole page is rendered as PDF..But i have a requirement that if i select lets say any 5 record from the table using the check box..then only that records should appear in the pdf

my vf page:

<apex:page controller="queryaccountrecords"  >
<apex:panelGrid columns="2">
<apex:form >
<apex:pageBlock title="Account_Records">
<apex:repeat value="{!accts}" var="dbItem">
<apex:inputCheckbox id="ankita"/>
<apex:outputField value="{!dbItem.Name}" /><br/>
</apex:repeat>
</apex:pageBlock>
<apex:commandButton value="Create PDF" action="{!createpdf}"/>
</apex:form>
</apex:panelGrid>
</apex:page>

my controller:

public class queryaccountrecords {
    public Account[] accts{get;set;}
    public queryaccountrecords()
     {
        accts= [SELECT Name FROM Account LIMIT 10];
    }

    public pagereference createpdf()
    {
    pagereference redirect = new PageReference('/apex/generatepdf');
    redirect.setRedirect(true);
    return redirect;
}
    }

page that is rendered as pdf:

<apex:page controller="queryaccountrecords" renderAs="pdf" showHeader="false" sidebar="false">
<apex:panelGrid columns="2">
<apex:form >

<apex:pageBlock title="Account_Records">

<apex:repeat value="{!accts}" var="dbItem">
<apex:outputField value="{!dbItem.Name}" /><br/>
</apex:repeat>
<apex:commandButton value="Create Pdf" action="{!createpdf}"/>

</apex:pageBlock>
</apex:form>
</apex:panelGrid>
</apex:page>
0
1

Check this link - https://developer.salesforce.com/page/Wrapper_Class

You have the code for process builder button, you're scenario should be same(selecting the checkboxes) you just include renderAs="pdf" in you're Visualforce.

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