You need to sign in to do that
Don't have an account?
Lukas R.
Render as pdf with header/footer
Hi,
Im trying to generate letter (pdf) using visualforce for campaign members who are contacts and have status 'Sent' with specific header and footer (see code below). This works fine however the result generated always includes one additional blank page with header/footer at the end. Im not really good at coding, can somebody help me out? Thanks a lot
Im trying to generate letter (pdf) using visualforce for campaign members who are contacts and have status 'Sent' with specific header and footer (see code below). This works fine however the result generated always includes one additional blank page with header/footer at the end. Im not really good at coding, can somebody help me out? Thanks a lot
<apex:page standardController="Campaign" renderAs="pdf" showHeader="false" sidebar="false" standardStylesheets="false" applyBodyTag="false" applyHtmlTag="false"> <html> <head> <style> @page { size: letter; margin: 25mm; @top-center { content: "Sample"; } @bottom-center { content: "Page " counter(page) " of " counter(pages); } } .page-break { display:block; page-break-after:always; } body { font-family: Arial Unicode MS; } </style> </head> <body> <div class="page-break"> <apex:repeat value="{!Campaign.CampaignMembers}" var="line"> <apex:outputPanel layout="block" style="page-break-after:always;" rendered="{!line.Status='Sent'}"> <apex:outputText value="{!line.contact.Name}," escape="false"/><br/> <apex:outputText value="{!Campaign.Test_Letter__c}" escape="false"/><br/> <apex:outputText value="S pozdravem," escape="false"/><br/> <apex:outputText value="Lukas" escape="false"/><br/> </apex:outputPanel> </apex:repeat> </div> </body> </html> </apex:page>
Since, "page-break-after:always;" will insert the blank page always. So, we need to render it based on some condition in order to get rid from the one extra blank page in last.
Since, You are using, StandardController , you can use extension to get the 'result size' of the standeard controller and you can render the ""page-break-after:always;" based on this condition.
I have created a small demo for you. Hope it will help you.
VF page -
Apex Controller - Please, let me know if it helps you.
Thanks,
Sumit Kumar Singh