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
Naveen Velkur 6Naveen Velkur 6 

Visual force page which generate pdf document , merge fields retrieve all the check box fields rather then selected one's.

We are using a Visual force page which generate pdf document , merge fields retrieve all the check box fields, requirement is "only selected check box Fields" needs to appear not all the check boxes like yes or no. 
Is there any solution to show only selected checkboxes, not all in the pdf document?
SubratSubrat (Salesforce Developers) 
Hello Naveen ,

To display only the selected checkbox fields in a Visualforce page that generates a PDF document, you can modify your code to include conditional rendering based on the checkbox values. Here's an example of how you can achieve this:
<apex:page renderAs="pdf">
  <h1>Selected Checkboxes</h1>
  <ul>
    <apex:outputPanel rendered="{!Red__c}">
      <li>Red</li>
    </apex:outputPanel>
    <apex:outputPanel rendered="{!Green__c}">
      <li>Green</li>
    </apex:outputPanel>
    <apex:outputPanel rendered="{!Orange__c}">
      <li>Orange</li>
    </apex:outputPanel>
    <apex:outputPanel rendered="{!Yellow__c}">
      <li>Yellow</li>
    </apex:outputPanel>
    <apex:outputPanel rendered="{!Violet__c}">
      <li>Violet</li>
    </apex:outputPanel>
  </ul>
</apex:page>
In this example, we are using the <apex:outputPanel> component with the rendered attribute to conditionally render each list item based on the checkbox values. Only the checkboxes that are selected (checked) will be displayed in the generated PDF document.

By using the rendered attribute with the checkbox fields, you can control the visibility of each list item based on their selected state. Only the selected checkboxes will be shown in the generated PDF document.

If this helps , please mark this as Best Answer.
Thank you.