Expand my Community achievements bar.

PageCount Reset/Restart

Avatar

Former Community Member

Hi!

I am in trouble with the currentPage/pageCount because i need to restart counting in different sections of the PDF module.

This is the situation:

MyPDF

- Master pages

     - Master Page 1

     - Master Page 2

- Page1 (fixed page, associated with Master1) pagecount expected: 1/x (according to the numbers of istances of Page2).

- Page2 (dynamic page... users can add mupliple istances of Page2, associated with Master1) pagecount expected: 2/2 or 2/x depending on number of istances.

- Page3 (fixed page, associated with Master2) pagecount expected (RESTART!): 1/x (according to the numbers of istances of Page4).

- Page4 (dynamic page...users can add mupliple istances of Page4, associated with Master2) pagecount expected: 2/2 or 2/x depending on number of istances.

- Page5 (fixed page, associated with Master2) pagecount expected: 1/1...

- ...

Page 1 & 2 must be counted togheter as part of same section: Page 1/2 and Page 2/2.

if page 2 have multiple istance (for example the user while compiling decide to add 2 pages), the currentPage/pageCount must increase dynamically than Page 1/4, 2/4, 3/4 & 4/4.

And this in not a problem.

Page 3... (Here is my issue!)

I need to restart/reset currentPage/pageCount indipendently from what was before and than Page 3 will be 1/x according to what follow.

Looking around, someone tell me to put one currentPage/pageCount in Master Page1 and another in Master Page2 but i was unable to make it work...

Any suggest?

Thx

3 Replies

Avatar

Level 10

Hi,

If you go to Master Page 2 and select the page number object. In the layout:ready event change the script to:

this.rawValue = this.parent.index + 1;

This is JavaScript and will use the instances of the second Master Page as the page number (plus 1, as it is a zero based system). 

Hope that helps,

Niall

Avatar

Former Community Member

Hi Niall,

first of all i wanna thank you for the time that you spent regarding my issues.

I found very helpfully your suggestion and it work great on currentPage.

I tried to put

this.rawValue = this.parent.index + 1;

...also to the pageCount on MP2 and unfortunately the result was another "current page" and not the total number of pages of second section.

Have you another tip?

Regads

Francesco

Avatar

Level 10

Hi,

How about on the second Master Page having the script in the layout:ready event of the Page Count field subtract the Page Count from the first Master Page.

this.rawValue = xfa.layout.pageCount() - Page1.PageCount.rawValue;

Would that work?

Niall