Auto-select correct month/page using system date

Community Beginner ,
Mar 17, 2019

Copy link to clipboard

Copied

I have a 12-page PDF calendar (1 page for each month).  How do I use javascript inside the PDF file to auto-select the current month page to display based on the user system date (month).  I am trying to display the current month of our club calendar that is launched from our webpage when the user selects "Calendar".

Presently, the PDF always displays the first page of the PDF file (January), and users must scroll down to select the current month.

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Add this code as a doc-level script:

this.pageNum = new Date().getMonth();

TOPICS
Acrobat SDK and JavaScript

Views

51

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

Auto-select correct month/page using system date

Community Beginner ,
Mar 17, 2019

Copy link to clipboard

Copied

I have a 12-page PDF calendar (1 page for each month).  How do I use javascript inside the PDF file to auto-select the current month page to display based on the user system date (month).  I am trying to display the current month of our club calendar that is launched from our webpage when the user selects "Calendar".

Presently, the PDF always displays the first page of the PDF file (January), and users must scroll down to select the current month.

Most Valuable Participant
Correct answer by try67 | Most Valuable Participant

Add this code as a doc-level script:

this.pageNum = new Date().getMonth();

TOPICS
Acrobat SDK and JavaScript

Views

52

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
Mar 17, 2019 0
Most Valuable Participant ,
Mar 17, 2019

Copy link to clipboard

Copied

Add this code as a doc-level script:

this.pageNum = new Date().getMonth();

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...
Mar 17, 2019 0
Community Beginner ,
Mar 17, 2019

Copy link to clipboard

Copied

Entered script as written - saved file and re-opened.  PDF is still opening on initial page.  What else is needed to execute the code?

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...
Mar 17, 2019 0
Most Valuable Participant ,
Mar 17, 2019

Copy link to clipboard

Copied

Nothing else is needed. Where did you enter it, exactly?

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...
Mar 17, 2019 1
Community Beginner ,
Mar 17, 2019

Copy link to clipboard

Copied

Ok - removed function name entered by Accrobat and removed brackets "{}".

Save and re-opened - now goes to March as it should.

Thank you for the 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...
Mar 17, 2019 1
Community Beginner ,
Mar 17, 2019

Copy link to clipboard

Copied

Entered the script from Try67 - saved and re-opened.  Still opening on initial first page.  What else is needed?

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...
Mar 17, 2019 0