Problem when using PageNumber system variable in watermark text!

Stimulsoft Reports.JS discussion
Post Reply
ossabla
Posts: 8
Joined: Fri Sep 17, 2021 10:06 pm

Problem when using PageNumber system variable in watermark text!

Post 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
Lech Kulikowski
Posts: 4069
Joined: Tue Mar 20, 2018 5:34 am

Re: Problem when using PageNumber system variable in watermark text!

Post by Lech Kulikowski »

Hello,

We need some additional time to investigate the issue, we will let you know about the result.

Thank you.
#5087
Lech Kulikowski
Posts: 4069
Joined: Tue Mar 20, 2018 5:34 am

Re: Problem when using PageNumber system variable in watermark text!

Post 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.
Attachments
ReportSample.mrt
(4.87 KiB) Downloaded 10 times
ossabla
Posts: 8
Joined: Fri Sep 17, 2021 10:06 pm

Re: Problem when using PageNumber system variable in watermark text!

Post 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
Andrew
Posts: 4093
Joined: Fri Jun 09, 2006 3:58 am

Re: Problem when using PageNumber system variable in watermark text!

Post by Andrew »

Hello,

Okay, thank you for sharing your knowledge!
Thank you.
Post Reply