Cfdocument family of tags

First, some details on my setup:
Virtual server with Windows Server 2016
Lucee 6.0.2.8-SNAPSHOT
Apache Tomcat 9.0.89
Java 11.0.22 (Eclipse Adoptium) 64bit

I am working with the <cfdocument> family of tags. I have found myself copying and pasting example code from others and having the code work. Meanwhile, I try to write what is seemingly the same code structure, and nothing is displayed - just a blank, full-page PDF. Specifically, I am having what seems like the most problem with the <cfdocumentitem> tags for the headers and footers.

Example of working code I found online:

<cfdocument format="PDF">
    <cfoutput>
        <!--- Section 1 --->
        <cfdocumentsection name="bookmark1">
            <cfdocumentitem type="header">
            <h1 style="text-align:center;">BIG FANCY HEADER</h1>
            </cfdocumentitem>
            Bacon ipsum dolor sit amet sirloin fatback #dateformat(now(), "short")#
            <cfdocumentitem type="footer">
            <h1 style="text-align:center;">Page #cfdocument.currentPageNumber# of #cfdocument.totalPageCount#</h1>
            </cfdocumentitem>
        </cfdocumentsection>
        
        <!--- Section 2 --->
        <cfdocumentsection name="bookmark2">
            <cfdocumentitem type="header">
            <h1 style="text-align:center;">2nd page header</h1>
            </cfdocumentitem>
            Bacon ipsum dolor sit amet sirloin fatback #dateformat(now(), "short")#
            <cfdocumentitem type="footer">
            <h1 style="text-align:center;">Page #cfdocument.currentPageNumber# of #cfdocument.totalPageCount#</h1>
            </cfdocumentitem>
        </cfdocumentsection>
    </cfoutput>
</cfdocument>

Example of my own code that generates a blank page:

<cfdocument format="pdf">
    <cfoutput>
        <cfdocumentsection name="test">
            <cfdocumentitem  type="header">
                <h1>Hello</h1>
            </cfdocumentitem>
             <cfdocumentitem  type="footer">
                <h1>Goodbye</h1>
            </cfdocumentitem>
        </cfdocumentsection>
    </cfoutput>
</cfdocument>

Asside from my example only having one , I cannot seem to find what the difference is between the two code blocks or why one displays output and the other does not. Can anyone spot what’s going on here?

Mike, it’s that the second example simply has no content BETWEEN the header and footer. Even CF returns essentially an empty page for this code.

Perhaps you expected it to offer a blank page–with the headers and footers filled in, at least. Neither engine does that, for whatever reason. If it’s intentional for you, do file a bug report or enhancement request.

Or let us know if it’s a surprise for you, to realize now you had no content between the cfdocumentitem tags. And if you meant to offer a different example, feel free.

Thanks, Charlie. I in fact did expect to see a header and a footer on an otherwise empty page. Where did you learn of this limitation? Is it documented somewhere, or have you come to it by experience?

It does make sense to a point, but I would have expected that at least on the first page it would be shown, even if there was no content.

Appreciate your insight.

Sorry: it’s that I simply tested it. :slight_smile: I see now that I forgot to mention that.

When I first just observed that difference, I then tested calling your code (on my own machine, using both engines). I ran it first as you had it, then I added a simple single line of text between the cfdocumentitem’s–and that’s when all the content showed up (body and headers).

Again, I agree that logically it would seem it should show the headers/footers regardless. But I have no dog in the fight, so again if you feel it SHOULD work then do file an enhancement request for Lucee and/or CF. :slight_smile:

1 Like