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

accessing a variable from differebt buttons

Community Beginner ,
Jan 29, 2017 Jan 29, 2017

Hello,

I would like to run a method which returns an array on opening the pdf file. Then I would like to access the returned array from different buttons.

How can I do it?

TOPICS
Acrobat SDK and JavaScript
681
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 29, 2017 Jan 29, 2017

If you define the variable at the doc-level (not inside a function), it should be available to all other code later on.

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 Beginner ,
Jan 29, 2017 Jan 29, 2017

But how?

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 30, 2017 Jan 30, 2017

Doc-level script:

var a = "abc";

Button-level script:

app.alert(a);

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 Beginner ,
Jan 30, 2017 Jan 30, 2017

I don't need to use global?

And where do I write the Doc level script, in order to let it reun on opening the file?

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 30, 2017 Jan 30, 2017

No.

All doc-level scripts are executed when the file is opened. You can add them under Tools - JavaScript - Document JavaScripts.

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 Beginner ,
Jan 30, 2017 Jan 30, 2017

I am using adobe acrobat 8 3D version.

It is under advanced> document processing> document javascripts

However it lets me add only functions.

It opens the JavaScript Functions window....

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 30, 2017 Jan 30, 2017
LATEST

Delete the default code and add your code instead. It doesn't have to be inside a function.

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