+ Start a Discussion
V AnandV Anand 

How to set number of records to PDF page?

I am using renderas attribute for displaying records in PDF format  like below format but some records are  split  into 2 pages in pdf .Now I want to set  no.of records  5 to each PDF page .How can I do that. 

 

any one help me please..........

 

Mr.Andy {Young
1301 Hoch Drive
Lawrence AndhraPradesh 66045
USA
Phone: (785) 241-6200

 

Mr.vissu
1301 Hoch Drive
Lawrence AndhraPradesh 66045
USA
Phone: (785) 241-6200

Best Answer chosen by Admin (Salesforce Developers) 
vriavmvriavm

Let us say you have a list of Sobject

youneed to create a wrapper class 

public class sobjectwrapper {

      sobject sobj { get;set; }

      Integer counter { get;set; }

}

 

Then once you have the list from soqlquery

loop through the list and create a list of sobjectwrapper with counter variable

use this class list in controller.

 

Please chat with me at vriavm@gmail.com if you need coding help...

All Answers

AravindBabu512AravindBabu512

Hi,

You can use pagination for this. Please have a look in the blog, you can get a better idea.  

Visualforce Page with Pagination

 

Thanks,

Aravind

Sudhakar ReddySudhakar Reddy

Hi,

 

You can use StandardSetController which provides you to set no of pages.

Please check once it .so you will get a good idea to solve your problem.

 

Regads,

Sudhakar Reddy

V AnandV Anand
Thank you for your reply......... But I have already used the standardsetcontroller .But not working for PDF page, It is working well for visulaforce page display.Is there any another way to solve it.
AravindBabu512AravindBabu512

Hi,

 

I was trying to explore into pagination with renderas PDF and i dont think we will have an option to achieve this. I just tried to show a list of records of a custom object in page as command link and clicking each record will take me to the detail page, but with the renderas PDF option the link doesnt work. And moreover, with this option a PDF with just 1 page (list of records) is getting created. I guess we dont have the option, please let the community know on your inputs/areas explored regarding this.

 

Thanks,

Aravind

vriavmvriavm

Hi,

 

          You can have a counter variable in the list you have and do a dynamic render of pagebreak in pdf based on the modulus operator like below:

 

              <apex:outputpanel rendered="{!IF(AND(MOD(Counter,10) == 0), true, false)}">                

                     <br/>

                     <DIV style="page-break-after: always"></DIV>

                     <br/>           

           </apex:outputpanel>

 

V AnandV Anand
Thank you ?for your reply .. But how can I declare count in list?
vriavmvriavm

Let us say you have a list of Sobject

youneed to create a wrapper class 

public class sobjectwrapper {

      sobject sobj { get;set; }

      Integer counter { get;set; }

}

 

Then once you have the list from soqlquery

loop through the list and create a list of sobjectwrapper with counter variable

use this class list in controller.

 

Please chat with me at vriavm@gmail.com if you need coding help...

This was selected as the best answer
V AnandV Anand
Hi............. If I use wrapper classes how to retrieve selected values in list view. My requirement is to create a pdf file for selected contacts in the list view.If I use wrapper classes then I have to write Soql ,with SOQL we cant able to fetch selected(with check box) records to visualforce. Please help me to achieve 5 records per pdf page .I am posting my extention controller. public class quickEmailController{ ApexPages.StandardSetController setCon; public quickEmailController(ApexPages.StandardSetController controller) { setCon = controller; } public pageReference doSomething() { for ( contact acc : (contact[])setCon.getSelected() ) { } return null; } }
V AnandV Anand

Thank you so much ....

 

I have solved my problem with your valuable suggestion.....