4

As of now , all i have is a VF page which renders as a PDF and it needs Account ID to be passed to generate a PDF . Is there a way wherein i can group all the PDF's into a single PDF ? Should i change the VF page structure to get multiple account ids or is there any easy way to add all PDF's into a single PDF?

1 Answer 1

5

There's no way to combine PDFs as such. What you would need to do is generate your PDF in a different way, i.e. from a List as opposed to the single record.

You can utilise the visualforce that you have already, and place it in an <apex:repeat/> block. For example, instead of e.g.

<apex:page standardController="Account" renderAs="pdf">
    <div> Account {!account.Name} </div>
</apex:page>

You might have:

<apex:page standardController="Account" recordSetVar="accounts" renderAs="pdf">

    <head>
        <style type="text/css">
           div.page {page-break-after: always;}
        </style>
    </head>

    <apex:repeat value="{!accounts}" var="account">
        <div class="page"> Account {!account.Name} </div>
    </apex:repeat>
</apex:page> 
4
  • I get your point . So is there a direct way to give page breaks between each pages in PDF when we use apex:repeat? Commented Sep 24, 2014 at 17:43
  • 1
    Yes, add some CSS - will update the answer Commented Sep 24, 2014 at 17:45
  • <div id="div1" style="page-break-before: always;"></div> - This has worked out well!!! Commented Sep 24, 2014 at 17:47
  • Yup, that will work too - updated answer to use css. That way will always leave a blank page at the end, you can prevent that by using other css selectors too Commented Sep 24, 2014 at 17:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .