1

I'm generation PDF in ColdFusion using <cfdocument> and I wanted to display the footer only on the last page. I found a solution here which works great and will display the footer on the last page only.

If your footer is long you will need to add marginbottom to the <cfdocument> tag in order to define the space, example:

<cfdocument format="PDF" unit="in" marginbottom="1.5" ... >

that means every page will have 1.5 inches of blank space at the bottom of it, is there a way to only apply that space only to the last page?

Community
  • 1
  • 1
Sammy
  • 3,059
  • 4
  • 23
  • 32
  • If you are only displaying text at the bottom of the last page it is not really a footer. Right? So why not just add your text at the end of your `` code block? That way you will not need to define the marginbottom which affects every page. – Miguel-F Aug 12 '14 at 16:48
  • @Miguel-F that way the footer will end up immediately after where the content ends and that could be somewhere in the middle of the page, unless it is positioned absolutely with bottom:0. with absolute positioning it could cover up content if it happens to end up where the footer is. – Sammy Aug 12 '14 at 17:10
  • Have you tried using `` at the end of your `` code block to define the footer? `` also allows you to specify a `marginBottom` for that section. [See documentation here](http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-791a.html) I will add an answer to illustrate what I think may work. – Miguel-F Aug 12 '14 at 17:47

1 Answers1

0

I have not tested this but it may work. Use <cfdocumentsection> tags to define specific areas of your <cfdocument> code block. <cfdocumentsection> also allows you to specify a marginBottom for that section only.

According to the docs:

Divides a PDF or FlashPaper document into sections. By using this tag in conjunction with a cfdocumentitem tag, each section can have unique headers, footers, and page numbers.

Try something like this:

<cfdocument format="PDF" unit="in" ... >
    <cfdocumentsection>
        <!--- All of your existing logic here --->
    </cfdocumentsection>
    <cfdocumentsection marginbottom="1.5"> 
        <cfdocumentitem type="footer" evalAtPrint="true">
            <cfif cfdocument.currentPageNumber eq cfdocument.totalPageCount>
                This is the last page footer
            </cfif>
        </cfdocumentitem>
    </cfdocumentsection>
</cfdocument>
Miguel-F
  • 13,450
  • 6
  • 38
  • 63