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
Priyesh Misquith 12Priyesh Misquith 12 

Conditional rendering of multiple PDF

I have the secnario where there are multiple visualforce component.

<apex: page renderAs='pdf'>
<c:componentA />
<c:componentB />
<c:componentC />
</apex: page >

when the field value in Opportunity  field__c = Apple
i want to download the pdf containing the details of   componentA and ComponentB on the click of the button
when the field value in Opportunity  field__c = Ball
i want to download the pdf containing the details of   componentA and ComponentC on the click of the button
when the field value in Opportunity  field__c = Cat
i want to download the pdf containing the details of   componentB and ComponentC on the click of the button

please let me know how can it be achived.
Best Answer chosen by Priyesh Misquith 12
ANUTEJANUTEJ (Salesforce Developers) 
Hi Priyesh,

I found a developer forum thread that mentions a way to render only particular tags based on boolean value that might be able to help.

https://developer.salesforce.com/forums/?id=906F0000000kA79IAE

Can you please have a look at it, looking forward to hearing back from you.

Regards,
Anutej

All Answers

ANUTEJANUTEJ (Salesforce Developers) 
Hi Priyesh,

I found a developer forum thread that mentions a way to render only particular tags based on boolean value that might be able to help.

https://developer.salesforce.com/forums/?id=906F0000000kA79IAE

Can you please have a look at it, looking forward to hearing back from you.

Regards,
Anutej
This was selected as the best answer
Dushyant SonwarDushyant Sonwar
Give this a try , replace the field as per your need.
<apex: page renderAs='pdf'>
<c:componentA rendered="{!OR(Opportunityfield__c == 'Apple' , Opportunityfield__c == 'Ball')}"/>
<c:componentB rendered="{!OR(Opportunityfield__c == 'Apple' , Opportunityfield__c == 'Cat')}"/>
<c:componentC rendered="{!OR(Opportunityfield__c == 'Ball' , Opportunityfield__c == 'Cat')}"/>
</apex: page >

Hope this helps!
Dushyant SonwarDushyant Sonwar
Priyesh,

Did you try with above solution? Does it solve your purpose?
Priyesh Misquith 12Priyesh Misquith 12

I tried with Anutej solution by creating the custom controller and setting Boolean rendering value Since i have nearly 30 component to render based on different scenrio .

but Dushyant your solution also helps the above scenario.

Thank you