Skip to main content
Nov 10, 2010 6:24 PM UTC
Question

Conditional header in CFDOCUMENT?

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 is closed to new replies. Start a new post to keep the conversation going.

    4 replies

    Inspiring
    Feb 24, 2012 7:34 PM UTC

    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>

    Translate
    Participant
    Jul 6, 2012 8:58 PM UTC

    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.

    Translate
    May 9, 2011 5:08 PM UTC

    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.

    Translate
    Inspiring
    May 9, 2011 6:09 PM UTC

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

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

    Translate