Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

PDF automation - JS script

New Here ,
Dec 30, 2019 Dec 30, 2019

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!

TOPICS
Acrobat SDK and JavaScript
845
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Dec 30, 2019 Dec 30, 2019

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;

 

Translate
Community Expert ,
Dec 30, 2019 Dec 30, 2019

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;

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 01, 2020 Jan 01, 2020

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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 01, 2020 Jan 01, 2020
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines