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>
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!