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

PDF automation - JS script

New Here ,
Dec 30, 2019 Dec 30, 2019

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!

TOPICS
Acrobat SDK and JavaScript

Views

539

Translate

Translate

Report

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;

 

Votes

Translate

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

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;

 

Votes

Translate

Translate

Report

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

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!

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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