Restoring Button Position

Engaged ,
Nov 25, 2017

Copy link to clipboard

Copied

Hi...

i changed some buttons position using (.rect) function, so the buttons is controlled with other buttons to make them go up and down or right and left, are there anyway  to restore the original position for the buttons! that was created first time before moving them ? , thanks for help

TOPICS
Acrobat SDK and JavaScript, Windows

Views

140

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

Restoring Button Position

Engaged ,
Nov 25, 2017

Copy link to clipboard

Copied

Hi...

i changed some buttons position using (.rect) function, so the buttons is controlled with other buttons to make them go up and down or right and left, are there anyway  to restore the original position for the buttons! that was created first time before moving them ? , thanks for help

TOPICS
Acrobat SDK and JavaScript, Windows

Views

141

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
Nov 25, 2017 0
Adobe Community Professional ,
Nov 25, 2017

Copy link to clipboard

Copied

There are a couple of ways.

1. Do not save the PDF. This way the buttons will always be at the position that was last saved.

2. Save a list of original coordinates in a hidden field. Use JSON so it'll be easy to set and get.

On this page ,  Free Sample PDF Files with scripts   , is a list of Sample PDF files, on it you'll find the "Swat the Fly" game, which is basically a button that moves around on the page. It does not solve your problem of saving the original position, its just an interesting sample of the process you've described.

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...
Nov 25, 2017 2
Engaged ,
Nov 26, 2017

Copy link to clipboard

Copied

Thank you,

yes i set a hidden copy of the button in the original position and now its easy to restore it back to its position with JSON, thank you..

i was using lingo (Macromedia Director Coding Language) and i always compare lingo with javascript, things much easier done in lingo and in lingo its easy to restore the rect becuase the software always remember the original rect or you can store it in Global Variable, i wonder if javascript for Acrobat have its own Global Variables or stuff like that will done from Document Level JavaScript,, Thanks 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...
Nov 26, 2017 0
Adobe Community Professional ,
Nov 26, 2017

Copy link to clipboard

Copied

Why yes, there are global variables in Acrobat JavaScript where the original position could be stored. For example, this codes stores a field rectangle into a document level variable. The scope of the variable is the document object, and it's lifetime is the lifetime of the document.

this.SaveRect = this.getField("Button1").rect;

You could also save to the global object.

global.SaveRect = this.getField("Button1").rect;

You can even make global objects persistent across Acrobat sessions.

I suggested a hidden field because it is persistent with the document, which is where the buttons live. If you don't need persistence, then a document level variable is easier than a field.

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...
Nov 26, 2017 2