PDF automation - JS script

New Here ,
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!

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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;

 

TOPICS
Acrobat SDK and JavaScript, Create PDFs, Edit and convert PDFs, How to

Views

146

Likes

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

PDF automation - JS script

New Here ,
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!

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

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;

 

TOPICS
Acrobat SDK and JavaScript, Create PDFs, Edit and convert PDFs, How to

Views

147

Likes

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
Dec 30, 2019 0
Most Valuable Participant ,
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;

 

Likes

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
Reply
Loading...
Dec 30, 2019 2
New Here ,
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!

Likes

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
Reply
Loading...
Jan 01, 2020 0
try67 LATEST
Most Valuable Participant ,
Jan 01, 2020

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.

Likes

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
Reply
Loading...
Jan 01, 2020 1