Hi All
I'm sorry, I feel like I'm asking a very basic question.
But still struggling understanding the "current page number" concept.
How can I detect the current page number when scripting in 'Main' subform element?
So, not in the MasterPage, but when populating the MastePage with a real content.
For example when printing list of products, I'm using a dataset (let's say 50 products)
and "Repeat subform for Each Data Item" checkbox in order to loop over product list and print each.
Let's say I wan't to add a JS inside the Product sub-subform that would detect the page number
and apply presence=hidden for a page element only when on 1st page.
Something like:
if( currentPage == '1' ){
this.presence='hidden';
}
When working with MasterPages I do the below trick, and it works totally fine (retutns 1, 2, 3 ... n)
this.rawValue = xfa.layout.page(this);
But when trying to use the same xfa.layout.page(this) in Main area I get the result of -1 (minus one) on each page
Then how can I detect the current page number inside my hypothetical Product subform?
Tried to follo radzmar's code snippet but ... the result is exactly the same
getting correct numbering on MasterPages (1, 2, 3 ... n) but -1 inside Main
this.rawValue = xfa.layout.pageContent( xfa.layout.absPage(this).toString(), "pageArea", true).item(0).index + 1;
PS. Adding scripts in the initialize* event, tried ready event as well but no difference.
Any comment appreciated.
bob
Views
Replies
Total Likes
Hi @bob_w1 ,
You can use below script on layout:ready event and it should work:
const pageNumber = xfa.layout.page(this);
if(pageNumber === 1){this.presence = "hidden";
}
I have created a sample XDP where subform present on first page will be hidden and subform present on second page will be visible while previewing the pdf.
Let me know if this works for you. Please also provide XDP designer version in case it does not work.
Thanks
Views
Replies
Total Likes
@bob_w1 Did you find the suggestions helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!
Views
Replies
Total Likes