How to get specific page numbers to each template (per language and Per instance) when the template itself repeatable | Community
Skip to main content
Level 6
March 1, 2026
Question

How to get specific page numbers to each template (per language and Per instance) when the template itself repeatable

  • March 1, 2026
  • 1 reply
  • 10 views

Hello All,

We have a single template with English and Spanish pages combined, and the same template can repeat based on data. With this use case, how to get the page numbers specific to language and instance?

Currently it returns total page counts, as page number calculated on master page default script.

Any suggestions on this use case to achieve?

 

When data for one Instance:

<form>

<Template>

     <English>

     </English>

     <Spanish>

     </Spanish>

</Template>

</form>

 

When data for multiple Instances:

<form>

<Template>

     <English>

     </English>

     <Spanish>

     </Spanish>

</Template>

<Template>

     <English>

     </English>

     <Spanish>

     </Spanish>

</Template>

</form>

 

Thanks,

Raghu.

    1 reply

    VishalKa5
    Level 5
    March 2, 2026

    Hi ​@Raghu_Nagireddy ,

     

    • Page numbering placed on the Master Page uses xfa.layout.page() and xfa.layout.pageCount() which always calculate page numbers at the document level.

    • Master Pages do not recognize boundaries of repeating subforms (Template instances) or language sections (English/Spanish).

    • Since the Template subform is repeatable, instance-specific page numbering must be calculated at the subform level, not the Master Page level.

    • Move the page number field inside the repeating Template subform.

    • Use JavaScript in the layout:ready event to calculate the current page relative to the starting page of that Template instance.

    • Logic:

      • Get current page using xfa.layout.page(this)

      • Get starting page of the current Template instance

      • Subtract start page from current page and add 1

    • For language-specific numbering, wrap English and Spanish sections in separate subforms and calculate page numbers relative to each language subform.

    • Ensure the Template subform is set to Flowed and configured as Repeat Subform for Each Data Item.

    In summary:
    Master Page → Global page count
    Subform-level scripting → Instance-level and language-level page count.

     

    Thanks,
    Vishal