Page 1 of 1
Problem when using PageNumber system variable in watermark text!
Posted: Mon Sep 27, 2021 5:46 pm
by ossabla
Hello,
When using variable system PageNumber as watermark text, the following problem occurs:
1. Number 1 is displayed on the first page as watermark - This is correct
2. Once again number 1 is displayed on the second page - This should be wrong in my understanding
3. Number 2 is displayed on the third page - Also not correct
Then number 3 on forth page and so on.
Can you please tell me the reason behind this behavior. I produced this behavior using the demo version yon our site.
https://demo.stimulsoft.com/#Js
Thanks in advance
Re: Problem when using PageNumber system variable in watermark text!
Posted: Wed Sep 29, 2021 7:53 pm
by Lech Kulikowski
Hello,
We need some additional time to investigate the issue, we will let you know about the result.
Thank you.
#5087
Re: Problem when using PageNumber system variable in watermark text!
Posted: Fri Oct 01, 2021 7:28 am
by Lech Kulikowski
Hello,
The PageNumber is a value whose exact value in textboxes is calculated only after the report is built. Due to the peculiarities of the engine, it may not be correct in other places.
In this case, you can use an additional variable or that task.
Thank you.
Re: Problem when using PageNumber system variable in watermark text!
Posted: Sat Oct 02, 2021 6:29 pm
by ossabla
Hello,
Thank you for the info provided.
I have fixed this issue by adding a custom function to the report :
var count = 0;
var function2 = function(pageNo){
if(pageNo === 1) return count++;
if(pageNo > 1) { count=0; return 1; }
}
and adding the following expression to the watermark text:
{PageNumber+CustomFunction(PageNumber)}
Actually, it is possible to use the custom function with minor modification so that it could be used without PageNumber variable but you have to reset the count variable after the last page else you will face a problem in design mode when you re-preview as the numbering will continue from where it stopped last time you previewed the report. But if you don't know how to get the last page this approach will be appropriate for this issue.
Now the the page numbers in watermark text works as expected in my scenario.
All the best
Re: Problem when using PageNumber system variable in watermark text!
Posted: Mon Oct 04, 2021 7:07 am
by Andrew
Hello,
Okay, thank you for sharing your knowledge!
Thank you.