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
Pavan KembaPavan Kemba 

How to renderPDF for List of Object

I have a requirement to generate PDF for list of Object.

I have a button and on click of it this there are certain Records inserted and i have to display these inserted records in a PDF.

I have a controller that returns list of ids, now i want to display these on PDF.

For Ex:
 

acctlist = [SELECT id FROM Account WHERE Account.Country='INDIA'];
Lets say this acctlist has 10records and details of these should be displayed in PDF. Each record, new Page.

How do i accomplish this. I have a VF Page renderedas PDF i dont know how to proceed further.
Pavan KembaPavan Kemba
I already have the VF PAge renderAs="PDF"
How to i populate the values on this Page from the list of Object IDs
Anil kumar GorantalaAnil kumar Gorantala
<apex:page controller="GeneratePDFListOfObjectRecords" renderAs="PDF">
  <apex:form>
    <apex:pageBlock title="Records Extracted">
        <apex:pageBlockSection title="Page Block Table">
   <apex:pageBlockTable value="{!accList}" var="account">
      <apex:column value="{!account.Id}"/>
      <apex:column value="{!account.name}"/>
   </apex:pageBlockTable>
        </apex:pageBlockSection>
</apex:pageBlock>
      </apex:form>
</apex:page>
 
public class GeneratePDFListOfObjectRecords {
	
    public list<account> accList{get; set;}
    
    public GeneratePDFListOfObjectRecords(){
        accList = [Select Id, name from account  where account.country='INDIA'];
    }
}

 
Pavan KembaPavan Kemba
Thanks Anil.
Tried your solution, but i'm getting a error telling UNKNOWN PROPERTY 'VISUALFORCEARRAYLIST.<THE FIELD NAME>'
 
Anil kumar GorantalaAnil kumar Gorantala
may be you are missing the variable

<apex:pageBlock title="Records Extracted">
<apex:pageBlockSection title="Page Block Table">
<apex:pageBlockTable value="{!accList}" var="account">   <!-- here account is the variable may be you are missing something.--->
. <apex:column value="{!account.Id}"/> <apex:column value="{!account.name}"/> </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageBlock>



can send me you code. and what you are doing
Pavan KembaPavan Kemba
Controller:
public List<Print_MCO__c> printmco {get;set;}

printmco = [SELECT id,Invoice_Date__c,Invoice_Number__c,VIN__c,Year__c,Make__c,Body_Type__c,Shipping_Weight__c,HP__c,GVWR__c,No_Of_Cylds__c,Model__c FROM Print_MCO__c WHERE id IN :mcoids];
return printmco;

VF Page:
 
<apex:page renderAs="pdf" controller="demoext" docType="html-5.0" title="Print MCO" cache="true" >
    <apex:form >
       	<apex:pageBlock >
                
                        <center>CERTIFICATE OF ORIGIN FOR A VEHICLE</center>
						<apex:pageBlockTable value="{!printmco}" var="mco">
            				<apex:column value="{!mco.id}"/>
                            <apex:column value="{!mco.Invoice_Date__c}"/>
                            
            			</apex:pageBlockTable>
		</apex:pageBlock>
    </apex:form>
</apex:page>


 
Anil kumar GorantalaAnil kumar Gorantala
everything seems good but I need whole code to find the mistake
Anil kumar GorantalaAnil kumar Gorantala
if you dont want to post code mail me anil_gorantala@epam.com
Pavan KembaPavan Kemba
I'm not supposed to send code outside Org nor share the complete code in blogs sorry Anil

The previous error is now fix as the list i was using was not made public

But the values are not getting printed now :(
 
<apex:page renderAs="pdf" standardController="Print_MCO__c" extensions="demoext" docType="html-5.0" title="Print MCO" cache="true" >
    <apex:form >
       	<apex:pageBlock >
            <center>CERTIFICATE OF ORIGIN FOR A VEHICLE</center>
            <apex:pageBlockSection >
            <apex:pageBlockTable value="{!printmco}" var="obj">
               
            	<apex:column value="{!obj.id}"/>
                <apex:column value="{!obj.Invoice_Date__c}"/>                
      

                
            </apex:pageBlockTable>
			</apex:pageBlockSection>
		</apex:pageBlock>
    </apex:form>
</apex:page>
Both columns are not printing values. The printmco list has around 7 records