Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

How do i dynamically update table of content page numbers as user inputs data and PDF gets larger?

Avatar

Level 2

I have a very large dynamic PDF and i have already built the table of contents but it only contains the title of each section (no page numbers). each item clicked focuses view on the corresponding Header of that section even if the page number changes. BUT now i need to add page numbers onto the table of contents page that will dynamically change as the document grows.  I'm new to LiveCycle.  Can anyone help? (I'm running LiveCycle ES4)

6 Replies

Avatar

Level 10

Hi,

you can use the page() Method to retrieve the current page number of an object.

Calculate script for a text field:

Returns the page number of the subform 'Chapter2' located on the page named "Page".


this.rawValue = "Chapter 2 - Lorem Ipsum Dolor \t\tPage " + xfa.layout.page(Page.Chapter2);


Avatar

Level 2

I'm not able to get this to work yet.  I'll explain what i'm currently doing and how i understand the script. (keep in mind still kinda new at this) It might be a bit confusing because you're using a "Page() method" and the page is named "page" so i'm not sure what part of the method is referring to the textfield. Also, i only have two "actual" pages in my PDF.  The subforms span pages and create new ones dynamically. Below are the minimized and expanded screenshots of what my document currently looks like.  The textfields for the table of contents will be placed on the TOC subform. 

Screen Shot 2014-11-05 at 9.30.15 AM.pngScreen Shot 2014-11-05 at 9.31.27 AM.png

I hope that helps. Could you let me know what each part of the method is doing so i know how to manipulate it for each table of contents item?  Thanks.

Avatar

Level 10

Hi,

if you want to get the page number of the the text field "Structure_Field" on Page 2 you use:

xfa.layout.page(Page2.StructureOfDistrict.Structure_Field); 

Avatar

Level 2

Sorry for the late response.  I'm getting the text in the script to show up dynamically in the text field now.

Chapter 2 - Lorem Ipsum DolorPage -1

but the page number always shows up as "1". it is not reading the correct page number. even when directing the script to place different text fields on different pages, it always reads "1".  any ideas on why?  below is the script that i redirected to the very last formfield in this 50+ page document and it is saying "Page 1".

this.rawValue = "Chapter 2 - Lorem Ipsum Dolor \t\tPage " + xfa.layout.page(PAGE2.Recommendations.Recommendations_Field);

Avatar

Level 10

The SOM expressions are case sensitive.

You screenshot shows a page named "Page2" but your script uses "PAGE2", which is not the same.

Avatar

Level 2

I had actually changed the name of my pages to all uppercase so not to get confused if "page" came up in any code.  the code is actually correct.  sorry, forgot to mention that.