What JavaScript Version for my Acrobat?

New Here ,
Jul 15, 2019 Jul 15, 2019

Copy link to clipboard

Copied

Hi,

I am using Acrobat Pro DC on Windows 10.

The JavaScript for Acrobat API Reference Manual (2015) page 1 (36) states: "The most recent version of Acrobat now uses JavaScript 1.7."

With a paragraph and table showing the following information that Acrobat 10 support JavaScript version 1.8.

However, when using JavaScript, the functions and features above JavaScript 1.5 are not available and will throw errors.

For example:

Math.trunc(42.7)  will give "TypeError: Math.trunc is not a function"

Same applies to default parameter values, binary number annotation, etc.

Thanks

Mohsen

TOPICS
Acrobat SDK and JavaScript, Windows

Views

171

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
community guidelines
Most Valuable Participant ,
Jul 17, 2019 Jul 17, 2019

Copy link to clipboard

Copied

The terms are confusing, but according to the Acrobat DC SDK documentation (Acrobat DC SDK Documentation ), Acrobat DC supports ECMAScript 5, which is one version prior to ECMAScript 2015 (AKA ECMAScript 6, ECMAScript - Wikipedia ), where the trunc method was first introduced (Math.trunc() - JavaScript | MDN ). So this method is not supported after 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
community guidelines
Adobe Community Professional ,
Jul 17, 2019 Jul 17, 2019

Copy link to clipboard

Copied

Yup, the different version numbers are confusing.

You can easily add the missing functionality in e.g. a document level script by adding this:

if (!Math.trunc) {

  Math.trunc = function (v) {

  return v < 0 ? Math.ceil(v) : Math.floor(v);

  };

}

This is a "polyfill" and you can usually add missing functionality this way to make modern JavaScript run in older JS engines.

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
community guidelines
New Here ,
Jul 18, 2019 Jul 18, 2019

Copy link to clipboard

Copied

Thank you all for the feedback and suggestions.

Is there any hope of the next Acrobat versions using a later version of JavaScript? ECMAScript 5 is already a 10 years' old version.

Thanks again.

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
community guidelines
Most Valuable Participant ,
Jul 18, 2019 Jul 18, 2019

Copy link to clipboard

Copied

LATEST

Only Adobe knows what will be included in future versions.

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
community guidelines