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?

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> 
| improve this answer | |
  • I get your point . So is there a direct way to give page breaks between each pages in PDF when we use apex:repeat? – TroubleShooter Sep 24 '14 at 17:43
  • 1
    Yes, add some CSS - will update the answer – Phil Hawthorn Sep 24 '14 at 17:45
  • <div id="div1" style="page-break-before: always;"></div> - This has worked out well!!! – TroubleShooter Sep 24 '14 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 – Phil Hawthorn Sep 24 '14 at 17:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.