1

Hello I have the below VF page which I use to generate a letter. I am not using "visualforce page that is rendered as PDF". I searched about "visualforce page that is rendered as PDF" but when I tried that out in my page it did not work.

<apex:page standardController="P__c" showHeader="false" extensions="Bclass">
<apex:form >
<apex:image url="{!imageURL}" style="width:720px" ></apex:image>

 <apex:panelGrid columns="2" width="720px">

       <apex:panelGrid columns="1" width="95%">        
            <span style="font-family: sans-serif; font-size:16px;"><b>DOB Job Number:</b> {!P__c.DOB__c}</span><br/>   
space:nowrap;"><b>Premises:</b> {!P__c.address__c}</span>
       </apex:panelGrid>


</apex:panelGrid>  
<br></br> 

<div id="container2" style="width:720px">
 <apex:repeat value="{!objlist}" var="d">
    <tr>
    <td><apex:outputText value="{!d}" style="font-family: sans-serif; font-size:16px;" /></td><br></br>
    </tr>
 </apex:repeat>
</div>
<!-- Want to add this image footer in all pages -->
<apex:image url="{!image_footer_URL}" style="width:720px" ></apex:image>
<!-- Want to add this image footer in all pages -->

<apex:commandButton action="{!Savecopy}" disabled="false" value="Save"/>

</apex:form>


</apex:page>

Some of the online answers assumes that <apex:page renderAs="pdf" is used in the VF page, but in my case I do not use this tag if you have noticed. I use the below code in my apex controller class to render a pdf version:

  public PageReference Savecopy(){
      PageReference p = Page.RSheet;
      blob b = ApexPages.currentPage().getContentAsPDF ();

      Attachment a = new Attachment();
      a.body = b;
      a.name = 'Sheet '+currentdate+'.pdf';
      a.parentid = pID;

      insert a;

      PageReference pref = new PageReference('/'+pID);
      return pref;
   }

How can I make this move to footer area. I want to make this footer visible in all the pages that are generated.

The answers at at this link- https://help.salesforce.com/apex/HTViewSolution?id=000003705&language=en_US does not fit in with my case. I need to do a work around for this, Is it possible?

2 Answers 2

1

Use a visualforce component that is the footer, then build a page that will be your template and add the footer in there.

Component (VF Component)

<apex:component>
   Your VF Footer markup
</apex:component>

Template (VF Page)

<apex:page>
    Header and body go first
    <apex:insert name="footer">
        <c:FooterComponentName>
    </apex:insert>
</apex:page>
6
  • I have an image variable which I use in footer. I get this image from a custom controller class. How can I include at in VF component?
    – SfdcBat
    Commented Nov 19, 2015 at 21:18
  • 1
    Either a) use a controller for your component or b) pass the value to your component using apex:attribute.
    – dsharrison
    Commented Nov 19, 2015 at 21:24
  • Can you show me a sample code how to do it?
    – SfdcBat
    Commented Nov 19, 2015 at 21:43
  • Components supports only standard controller and my logic is in extension
    – SfdcBat
    Commented Nov 19, 2015 at 21:44
  • Tried this- "<apex:component standardController="P__c" extensions="Bexten">" But I get an Error: Unsupported attribute standardcontroller in <apex:component> in check at line 1 column 54
    – SfdcBat
    Commented Nov 19, 2015 at 21:55
2

follow this link.

https://help.salesforce.com/apex/HTViewSolution?id=000003705&language=en_US

nice example for Adding page header/footer into a VisualForce page

If you are not using pdf then you may want to use apex:define and apex:composition

Here the examples https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_define.htm

http://www.infallibletechie.com/2013/04/apexinsert-apexcomposition-apexdefine.html

This a Jsfiddle http://jsfiddle.net/Ratan_Paul/2vxvhzce/ for html fixed header and footer

Here is example with two VF pages and common controller

https://gist.github.com/RatanPaul/2c1e04b0f7846ca333bc

14
  • Hello , But I do not use <apex:page renderAs="pdf">, Please see my edits on top.
    – SfdcBat
    Commented Nov 22, 2015 at 16:58
  • @Rdvsm. updated ans plz check. May this will help you
    – Ratan Paul
    Commented Nov 22, 2015 at 17:19
  • Hi, I tried this and made a difference, however as I generate the content of the body dynamically on the page, the footer does not go at the bottom of all the pages and appears in the middle when the content in the body is less. I use <br></br> in "template" file to move the footer to the bottom for a page. Can I make any change(may be add css style?) to keep the footer always at the bottom of the page?
    – SfdcBat
    Commented Nov 22, 2015 at 17:55
  • I think you need like this.. plz check Jsfiddle jsfiddle.net/Ratan_Paul/2vxvhzce Also update my ans plz check
    – Ratan Paul
    Commented Nov 22, 2015 at 18:01
  • Thanks, the footer works when I preview my VF page , however when I view the generated pdf, the content of the footer moves up and does not appear as expected. Any changes to be made to reflect in pdf too? Thanks
    – SfdcBat
    Commented Nov 22, 2015 at 18:12

You must log in to answer this question.

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