Copy link to clipboard
Copied
Hi!
I want to do such a thing:
- add the active field (click) to a specific place in the PDF file (button - I know how to do it)
- create a script in JS that will show me the number of today (e.g. 320 day this year)
- move to a specific page (the result of the script No. 1) - e.g. to page 320
Could you help me with these scripts?
Thanks!
1 Correct answer
Not sure what you mean by the first point.
Where do you want to show this number?
You can use something like this:
var now = new Date();
var start = new Date(now.getFullYear(), 0, 0);
var diff = (now - start) + ((start.getTimezoneOffset() - now.getTimezoneOffset()) * 60 * 1000);
var oneDay = 1000 * 60 * 60 * 24;
var day = Math.floor(diff / oneDay);
this.pageNum = day-1;
Copy link to clipboard
Copied
Not sure what you mean by the first point.
Where do you want to show this number?
You can use something like this:
var now = new Date();
var start = new Date(now.getFullYear(), 0, 0);
var diff = (now - start) + ((start.getTimezoneOffset() - now.getTimezoneOffset()) * 60 * 1000);
var oneDay = 1000 * 60 * 60 * 24;
var day = Math.floor(diff / oneDay);
this.pageNum = day-1;
Copy link to clipboard
Copied
Thank you @try67 That's what I needed 🙂
I run this script after clicking the active field (link) and it works great ... but only in Adobe Acrobat.
Is it possible to run JS scripts in other apps as well? For example standard Apple Preview.
Thank you for your help!
Copy link to clipboard
Copied
That's up to the developers of those applications. Apple Preview is known to be a very bad application, and it corrupts PDF forms just by opening them. I would recommend you don't use it at all.

