2

Everything I have found about CFPDF says that the way to add page numbers to a PDF is like this

<cfpdf action="addFooter" source="#finalFile#" name="mypdf" 
       text="Page _PAGENUMBER of _LASTPAGENUMBER" />

The problem is every reference I have found is for coldFusion 9 and before and I am wondering if maybe the Lucee guys didn't include this functionality because I get an error that says

Attribute text is not allowed for tag cfpdf

Is this a syntax issue or an oversight by Lucee/Railo not to put this in.

I am merging a group of PDFs using CFPDFs merge feature that this is working correctly but I now need to put page numbers on the PDF and that is were I am hitting a wall.

Here is the a more complete picture of what I am trying to do. The only part that isn't working is the addFooter line

    <cfpdf action = "merge" destination="#finalFile#" overwrite="yes"> 
        <cfloop array="#arrayOfPdfs#" index="k">
            <cfpdfparam source="#k#">
        </cfloop>
    </cfpdf>

    <cfpdf action="addFooter" source="#finalFile#" name="mypdf" 
           text="Page _PAGENUMBER of _LASTPAGENUMBER" />

    <cfloop array="#arrayOfPdfs#" index="k">
        <cffile action="delete" file="#k#">
    </cfloop>
Lance
  • 3,193
  • 2
  • 32
  • 49

1 Answers1

5

I did a little searching and here is what I found. Remember that Lucee was previously Railo. I found your exact issue reported as a bug in Railo back in August 2011 - cfpdf addfooter not supported It looks like that bug was never addressed.

The Lucee docs mention the ability to add a header/footer using cfpdf in the lead-in paragraph but not in the tags attributes - Lucee documentation for cfpdf

Create PDF portfolios - Add and remove header/footer from PDF documents - Optimize PDF documents

(my emphasis) But there is no mention of addheader or addfooter beyond that.

This just mirrors the original Railo documentation - Railo documentation for cfpdf

I am guessing that this bug was never resolved and now exists (still exists) in Lucee. I would create a new issue for the Lucee group to revisit this - https://luceeserver.atlassian.net/secure/Dashboard.jspa

It is interesting that it seems to accept the addfooter action just not the text attribute. That makes it seem like a bug.

UPDATE 11/18/2021

From Andy's comment below "It looks like a fix is coming from the PULL requests at github.com/lucee/extension-pdf/pulls specifically github.com/lucee/extension-pdf/pull/31" it appears that a fix may finally be coming for this issue. Thanks for the update Andy!

Miguel-F
  • 13,450
  • 6
  • 38
  • 63
  • I have registered this as a bug but given that it is as old as it is I may have to come up with an alternate solution :( – Lance Jan 19 '16 at 23:43
  • It looks like a fix is coming from the PULL requests at https://github.com/lucee/extension-pdf/pulls specifically https://github.com/lucee/extension-pdf/pull/31 – Andy Jarrett Nov 18 '21 at 11:27
  • Thanks for the information. I will add that to the answer in the form of an update so it is more visible for others reaching this page. – Miguel-F Nov 18 '21 at 13:55
  • You can (like I have today) pull the pull request in to a new local branch, and using ANT compile the extension and deploy it if you want it sooner. e.g. git fetch origin pull//head: git checkout – Andy Jarrett Nov 18 '21 at 15:00