2

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

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

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 :)

  • 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 Mar 28 '19 at 8:00
3

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

  • 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 Jan 11 '17 at 8:11

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.