3

For our quote PDF i am trying to get a table containing the customer invoice/delivery address to float to the bottom of the PDF page, however when I try usual CSS I get a PDF generation error.

Is there a way to make the table snap to the bottom og the page? Below is an example of what i would like: enter image description here

3

You should define the @page size and footer style like this:

<apex:page showHeader="false" renderAs="pdf">

<head>
<style>
    @page {
        size: 21.0cm 29.7cm;
        margin-top:    1cm;
        margin-left:   1cm;
        margin-right:  1cm;
        margin-bottom: 0cm;
    }

    #footer{
        position:absolute;
        left:0; top:26cm; width:20cm; height:2.5cm;
    }
</style>
</head>

<div id="content">
    Main Content Here
</div>

<div id="footer">
    <table style="width:100%;">
        <tr><td>Your Footer Text Here</td></tr>
    </table>
</div>

</apex:page>
  • This seems to work, except if there a lot of line items on the quote then the line items render behind the box as this doesn't get pushed down onto the next page (if needed) – Carl S Apr 15 '15 at 14:08
  • First, getting good control over PDF styling with CSS is hard in Visualforce, so be prepared for a lot of trial and error. In the example above, one thing you could do is to set the height of the footer element based on the number of line items. So you'd replace the "2.5cm" with a method call to your controller which returns number of line items times some size value that correlates with the real estate a line item takes up in VF. – jkraybill Apr 20 '15 at 5:19
0
<sethtmlpagefooter name="footer_name" value="on"/>
<htmlpagefooter name="footer_name">
<!--- html code -->
</htmlpagefooter>

https://mpdf.github.io/headers-footers/headers-footers.html - Headers & Footers in docs

  • Hmm, I'm not sure that this will work if the PDF is being generated from within Salesforce. Usually, PDFs are generated from a Visualforce page (and then calling getContentAsPDF() in Apex, or setting the renderAs attribute of the <apex:page> tag to "pdf"). – Derek F May 5 '18 at 12:29
  • This answer is also pretty close to being a "code dump" (an answer where you provide a block of code, and no explanation). Answers are better when you include explanation. In this case, I would explain: what "mpdf" is, that it provides a tag specifically for footers, and (crucially) how to make use of this from within Salesforce. – Derek F May 5 '18 at 12:34
  • It would appear to be a PHP library, hence no relevance to Salesforce at all. – Charles T May 5 '18 at 15:33

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.