[Ultimate PDF] Obtain page number programatically
Forge component by Leonardo Fernandes
Application Type
Traditional Web

Hello everybody. Great plugin!

We have a requirement in which we need to print some dynamic information in the header of a PDF, like this:

  1. Header
    1. Current datetime
    2. SourceRecordList[PageNumber].someVariable
    3. PageNumber / PageCount
  2. MainContent
    1. SourceRecordList
      1. Loop
        1. SourceRecordList[i].content
      2. PageBreak
  3. Footer
    1. Static text

So, in my first page, in the header, we need to print the SourceRecordList[0].someVariable. For the second page, SourceRecordList[1].someVariable, and so on.

Due to PageNumber and PageCount requirements of being inside the header or footer, we cannot insert the header inside the MainContent SourceRecordList loop in order to access the SourceRecordList[i].someVariable.

Is there a way to access or use the PageNumber variable (i) inside an expression, even in the header?

Thanks in advance.

Hello Fergardi,

It is a reasonable ask for sure, but unfortunately we cannot access the PageNumber widget's runtime value inside an expression using UltimatePDF in it's current form.

There is definitely a case for such a request, because there have been other requests from the community members where for e.g. they would like to be able to set footers only on certain PageNumbers (such as the last page) etc.



Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.