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

Get Object Name Using Javascript

Contributor ,
Dec 22, 2016 Dec 22, 2016

Hi,

Using Acrobat Professional DC, wondered if it is possible to create a script to get the name of an object for example as an event target (for example, on entering a page?).

If I can get an object's name, then possibly I could add a script to change its fill color or some other property?

Am learning scripting in Acrobat, have been reading the scripting API, correct syntax, and would appreciate any help to get an object's name based on an event.

Thank you in advance.

Stephen

TOPICS
Acrobat SDK and JavaScript
2.3K
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

correct answers 1 Correct answer

LEGEND , Dec 23, 2016 Dec 23, 2016

The drawn content you make with FrameMaker is not bundled into objects, does not have names, and such content cannot have its attributes read or changed from JavaScript at all.

Translate
LEGEND ,
Dec 23, 2016 Dec 23, 2016

What sort of object exactly? Most objects don't have a name.

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
Contributor ,
Dec 23, 2016 Dec 23, 2016

I am using Adobe Framemaker to create a guide that is published to Acrobat PDF (using my installed Acrobat DC printer-this is how Adobe Framemaker seems to publish to PDF).

So, if I add a graphic shape (draw a rectangle with a fill) in Framemaker, and would like to create a new script in Acrobat to change that graphic object (change its color, transparency, etc.), I am not sure what to use for an object name that will be recognized and work in Acrobat's Javascript. Not sure how to reference it in the script?

I tested using a drawn rectangle, and when I view it in Acrobat's Content pane, on the page where the rectangle is, the rectangle seems to have 5 "Path" names, each the same name ("Path") one for each side, and the fifth "Path" is the whole rectangle. So, if I wanted to write a script to change a feature (fill, transparency, etc.) for this object, I am unsure how to call this object in the script?

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 ,
Dec 23, 2016 Dec 23, 2016

Not possible with Acrobat JavaScript.

On Fri, Dec 23, 2016 at 2:29 PM, saratogacoach <forums_noreply@adobe.com>

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
LEGEND ,
Dec 23, 2016 Dec 23, 2016

The drawn content you make with FrameMaker is not bundled into objects, does not have names, and such content cannot have its attributes read or changed from JavaScript at all.

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
Contributor ,
Dec 23, 2016 Dec 23, 2016

Is there a way to create a graphic object in Acrobat DC, get a name for it and use the name in a script?

For example, I would draw the graphic object (rectangle, circle, etc. ) in Acrobat (if this can be done), get and use its object name in a script added to a button, to let the person viewing the PDF change the background color/fill.

That would also work, if possible?

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 ,
Dec 23, 2016 Dec 23, 2016

Yes, you can do it using comments (annotations, in their technical name), or form fields (but those are only rectangular).

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
Contributor ,
Dec 23, 2016 Dec 23, 2016

How would I get an object name to use in a script?

I tried by using Commenting, drew a blue circle (object name: "Circle"). What is the object name if I want to use it in a script to for example change the fill color to green?

If I create 10 circles on 10 different pages, and each has the same name ("Circle"), how do I identify the "Circle" on page 4 in a script to only change that one circle's fill color? Is it Page4.Circle ?

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 ,
Dec 23, 2016 Dec 23, 2016

You need to study the relevant methods of properties relating to

annotations. Each one has a name property with a unique value.

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
Contributor ,
Dec 23, 2016 Dec 23, 2016

Thank you.

I'll do some reading. (Hopefully can find this information in the Adobe JavaScript API guide?)

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 ,
Dec 23, 2016 Dec 23, 2016

Correct. Focus on the Annotation object and the relevant methods of the Document object (namely getAnnot, getAnnots and syncAnnotScan).

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
Contributor ,
Dec 23, 2016 Dec 23, 2016
LATEST

Thank you.

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