Skip to main content
November 10, 2010
Question

Conditional header in CFDOCUMENT?

  • November 10, 2010
  • 2 replies
  • 3164 views

I searched around, but could not find a specific answer to this one.

I have a pretty basic report with a cover page that should have no headers or footers, and the rest of the report which should have the same header and footer on each page.

I can't figure out how to use cfdocument so that the header and footer do not appear on the first page. I tried using this code which didn't work:

<cfdocumentitem type="header"  >

        <cfif cfdocument.currentpagenumber GT 1>

        <div style="border-bottom:1px solid #673951;padding-bottom:20px;float:left;width:100%"><img src="../images/logo_print_150.jpg" width="180" height="52" /></div>

            </cfif>

</cfdocumentitem>

Is there a way around this?

    This topic has been closed for replies.

    2 replies

    Inspiring
    February 24, 2012

    I realize this is well over a year after the original post, but I just came across it look for an answer to a question I had, maybe it will help someone someday.

    There's a simple way to do this. Headers and footers not used inside a cfdocumentsection apply to the whole document. But used inside cfdocumentsection tags only apply to that section. So it can be done as follows:

    <cfdocumentsection>

         cover page goes here

    </cfdocumentsection>

    <cfdocumentsection>

         <cfdocumentitemtype="header">

              header goes here

         </cfdocumentitem>

         main body goes here

    </cfdocumentsection>

    Participant
    July 6, 2012

    The trick to this, is that if you don't explicitly know where the page break will occur, you can't reliably wrap "just" the first (or second or third...) page  with a section tag such that you can then control the header.

    May 9, 2011

    I know im several months late in responding to this but here goes...(Sorry not a lot of help here..but some validation)

    This seems to work fine for me when doing a footer but there are issues with running a conditional in the header ... for some odd reason.  What you are doing is what I am using in the footer and no issues.  I copy that to the header...should work right? Nope.

    Adobe still has some work to do on making PDF's working properly with ColdFusion.  Seeing as they also author Acrobat you would think this woudl be a no brainer...guess not.

    Inspiring
    May 9, 2011

    Are you using the evalAtPrint attribute? See documentation for more info.

    http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7758.html