Can't use cfdocument.currentPageNumber in an expression

Hi
We know cfdocument.currentPageNumber only works in ColdFusion. Am I the only person who needs this?

Does anybody have a work around so that page totals can be printed with Lucee?

TIA

Tony

It is possible to use these in Lucee but NOT as an expression…

Note: The cfdocument scope variables are reserved for page number rendering. Do not use them in ColdFusion expressions.

http://underpop.online.fr/d/dreamweaver/8/coldfusion/cfdocument.htm


Note: The cfdocument scope variables are reserved for page number rendering. Do not use them in ColdFusion expressions. For example, the following code does not work:

<cfif cfdocument.currentpagenumber gt 1> 
  <cfoutput>#cfdocument.currentpagenumber-1#</cfoutput> 
</cfif>
1 Like

Is this the bug? [LDEV-1546] - Lucee vote for it

Yes - I’ve done the vote for it too…

When ACF brought this in in CF8 the cfdocument.currentpage etc could not be accessed beyond a simple print out which is the same as Lucee at the moment. ACF must have changed it along the way.

It’s really useful for invoicing and similar outputs where there are differing lengths of recurring lines…

How do people solve the alternate printing in Lucee based on content? Counting pages does not work…

Tried google but can’t find any solution… Anybody have a workaround?

I’m hitting the same issue. No workaround that I’m aware of. We’ll need to lobby to get the following bug fixed:
https://luceeserver.atlassian.net/browse/LDEV-1546

with the new or the old pdf engine?

I’m using 5.3.2.77…

Can you chime in on the bug, as that bug was logged against the old pdf engine (i.e pre 5.3)

It’s good to also mention which PDF extension version you are using

I updated the ticket to include…


Still an ongoing issue. You can’t evaluate the value of cfdocument.currentpagenumber so its impossible to adjust page numbering in . Adjusting the page number can be critical if you are combining multiple PDFs together.

Using extension v1.0.0.66 and v1.0.0.72

Here is a simple example that highlights the issue:

<cfdocumentitem type="footer"> 
	<cfoutput>
		<span style="font-family: Arial, sans-serif;font-size: 8px;">
		#cfdocument.currentpagenumber+1# / #cfdocument.totalpagecount#
		</span>
	</cfoutput>
</cfdocumentitem>

Generates the following error:

can't cast [{currentpagenumber}] string to a number value

Which implies that currentpagenumber is not a standard variable.

PDF extension is 1.0.0.73-SNAPSHOT on 5.3.2.77

@Eggely
Could you give a try with the below code, loop over the cfdocument is the workaround for this issue

<cfdocument format="pdf">
	<cfoutput>
        <p style='page-break-after:always;'>&nbsp;</p>
        <p style='page-break-after:always;'>&nbsp;</p>
         <p style='page-break-after:always;'>&nbsp;</p> 

		<cfdocumentitem type="header" evalatprint="true">
			<Cfloop collection="#cfdocument#" index="i">
				Page #cfdocument["currentpagenumber"]#
				<cfbreak>
			</Cfloop>
		</cfdocumentitem>
		<cfdocumentitem type="footer" evalatprint="true">
			<Cfloop collection="#cfdocument#" index="i">
				Page #cfdocument["currentpagenumber"]#
				<cfbreak>
			</Cfloop>
		</cfdocumentitem>
	</cfoutput>
</cfdocument>

is the problem that Lucee is internally assuming that {currentpagenumber} is a dateformat like {ts ‘2019-07-12 14:45:25’} and the detection of such date formats needs to be a bit stricter?

That gives two page numbers on each page - no problem there…

If I try

<cfif cfdocument.currentPageNumber IS cfdocument.totalPageCount>test</cfif>
or
<cfif #cfdocument["currentpagenumber"]# IS #cfdocument["totalPageCount"]# >test</cfif>

then nothing happens - this is not evaluated

Yeah right Zac, these are the lines.

1 Like

Hi we are using Lucee 5.2.9.31, we are using the <cfdocument and inside that , this code is working fine ACF but in the lucee , it is not giving desired output in case of css formating and page number display , can any one help in this , how can we get the pagenumber in document using in lucee?

You can vote for the page number bug in Jira.

As for CSS formatting, there’s a new pdf engine, flying saucer in 5.3, the older pdf engine won’t be updated anymore due to some inherent problems.

If you can reproduce the CSS problem in the new engine (make sure you are using the latest pdf extension) and it hasn’t already been reported in jira, file a new bug with a simple test case (or vote for the existing bug if you find one)

Running into this issue when trying to display a footer for the last page of a document only, but of course the evaluation does not work in Lucee where it works properly in ACF.

Is there a workaround for this? I get the impression the cfdocumentitem footer is going to have to be replaced with a DIV that will somehow align to the bottom of the generated PDF page… not sure how to correctly accomplish this though within the cfdocument.

1 Like