4

I have read a lot of topic about pdf footers but nothing allows me to add my footer on ALL my pages :

<apex:page standardController="Opportunity" extensions="FicheSocieteController" showHeader="false" sidebar="false" standardStylesheets="false" renderAs="pdf" applyBodyTag="false" applyHtmlTag="false">
<head>
    <style type="text/css" media="print">
        @page {
            margin-bottom: 3cm;

            @bottom-center {
             content: element(footer);
            }
        }

        div.footer {
            display: block;
            padding: 10px;
            position: running(footer);
        }

    </style>
</head>
<body>
    <!--some elements-->
    <div class="footer" name="footer">
        <!--my footer-->
    </div>
</body>

The footer is display only at my second page if have 2 pages (if I have a lot of text in the page) If I have only one page the footer is displayed correctly, but I'd like to display it in all the pages

4
  • Did you try to remove the footer from the body tag? Commented Jan 10, 2017 at 15:13
  • I just tried your idea, but it don't works either
    – dou
    Commented Jan 10, 2017 at 15:18
  • On the documentation, they don't use a body tag but a special class 'content'. Commented Jan 10, 2017 at 15:20
  • I try to replace with this tag but nothing changed...
    – dou
    Commented Jan 10, 2017 at 15:53

2 Answers 2

10

I finally resolve my problem by putting the <div class="footer"><some footer here</div> BEFORE the content of my page. This way I can see the footer on all the pages. If any of you know why this is acting this way, I'd like to hear it :)

1
  • I tried putting this footer just after page declaration and stylesheet declaration, it worked. Again i am not sure why. Please must comment if any one is aware of it.
    – karan
    Commented Mar 28, 2019 at 8:00
5

I think you almost got it but missed two minor things.

  1. You mentioned applyHtmlTag="false" but there is no HTML tag in the code.

  2. You have div tag for footer but there is no content inside it. Try add something in it.

I made these changes to your code:

<apex:page  standardController="Opportunity"
            extensions="FicheSocieteController" 
            showHeader="false" 
            sidebar="false" 
            standardStylesheets="false" 
            renderAs="pdf" 
            applyBodyTag="false" 
            applyHtmlTag="false">
    <html>
        <head>
            <style type="text/css" media="print">
                @page {
                    margin-bottom: 3cm;

                    @bottom-center {
                     content: element(footer);
                    }
                }

                div.footer {
                    display: block;
                    padding: 10px;
                    position: running(footer);
                }

            </style>
        </head>
        <body>
            <!--some elements-->
            <div class="footer" name="footer">
                <p>Footer</p>
            </div>
            <!-- Add some long text here -->
        </body>
    </html>
</apex:page>

Output:

Footer for page 1:

enter image description here

Footer for page 2:

enter image description here

1
  • Thank you for the answer, I have not wrote it here because I do not wanted to surchage the code sample, but in place of <!--my footer--> I have some html tag. So I have something like you. Nevertheless I tried you code but I still have the same result : the footer is only displayed in the second page.
    – dou
    Commented Jan 11, 2017 at 8:11

You must log in to answer this question.

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