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

Get selected field(s)

Explorer ,
Dec 13, 2017 Dec 13, 2017

When in "Prepare Form" mode in Adobe Acrobat Pro DC, is there a way to get the selected field name(s) via JavaScript? I would like the user to be able to select a field (or multiple fields), and then click a custom button under "Add-ons" so that I can bring up my own custom dialog. I don't want to write a C++ plugin. Thanks in advance.

TOPICS
Acrobat SDK and JavaScript , Windows
2.7K
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

Community Expert , Dec 13, 2017 Dec 13, 2017

No, can't be done.

Translate
Community Expert ,
Dec 13, 2017 Dec 13, 2017

No, can't be done.

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
Explorer ,
Dec 13, 2017 Dec 13, 2017

Thanks for the reply. Is there any work around for this? Or do I need to create a generic dialog that gives them a field selection list where once they select a field I programmatically modify some of the properties I'm allowing them to change? In this case metadata...

Also, can this be done in C++? Also wondering if I could add a context menu item via C++ and have it call a JavaScript function passing the field name in context or is there no way to bridge the two programming languages?

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 13, 2017 Dec 13, 2017

If that's what you want to do then yes, you would need to display a list of the field names and have the user select from it (or have them enter the field's name into a text field, or something like that).

I don't know about whether it can be done using C++. Try the Acrobat SDK forum. I doubt it, though.

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
Explorer ,
Dec 13, 2017 Dec 13, 2017

Ok thanks. And just to confirm, there's no way to add to the "Field Properties" UI is there?

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 13, 2017 Dec 13, 2017

Not with JS.

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 13, 2017 Dec 13, 2017

You cannot modify anything in the Prepare Form tools from the standard API/SDK (JS or C++).  Unless of course you are working with MS Windows and you know how to subclass windows and hijack messages, then of course, you can create a plug-in that gets in there. But it won't do you much good.

What exactly do you want to do? There is probably another way.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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
Explorer ,
Dec 14, 2017 Dec 14, 2017

Thanks for the reply. I would like to either:

  1. Be able to add an item to the context menu that shows up when you right click on a field when preparing the form so that I can bring up a dialog to edit metadata associated with the selected field.
  2. Be able to select a field, then click a custom button under add-on tools which would run JavaScript and ideally get a reference to the selected field so that when the metadata dialog comes up I already have the metadata for the selected field loaded rather than them having to always select the field they want to change the metadata for in the dialog each time.
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 14, 2017 Dec 14, 2017

What field metadata are you referring too?

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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
Explorer ,
Dec 14, 2017 Dec 14, 2017

I'm just storing arbitrary metadata for some of the form fields under document.info.

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 14, 2017 Dec 14, 2017

the "info" object contains document metadata, not field metadata.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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
Explorer ,
Dec 14, 2017 Dec 14, 2017

Right, it's document metadata which I'm using to store metadata about certain fields since I'm not aware of any other place to store metadata associated with fields?

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 14, 2017 Dec 14, 2017

If you look down the list of field properties you'll find only a single one that can contain arbitrary text and not screw up the field, "userName" .  This is the popup text displayed when the mouse hovers over the field.  So you're correct.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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
Explorer ,
Dec 14, 2017 Dec 14, 2017
LATEST

Ok, thanks for the help!

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 14, 2017 Dec 14, 2017

But you can do this as I pointed out earlier, you just can't detect which fields are selected.

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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 14, 2017 Dec 14, 2017

See this article:

Alerts, Popups, and Other Devices for Interacting with the User

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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 14, 2017 Dec 14, 2017

You can create toolbar buttons with either a plug-in or JavaScript, but neither has the ability to detect a selected field. However, you could provide the user with a list of fields that are visible on the page.And then set you metadata from there.

But what metadata are you talking about? 

Thom Parker - Software Developer at PDFScripting
Use the Acrobat JavaScript Reference early and often

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
Explorer ,
Dec 14, 2017 Dec 14, 2017

Yep, ok, that's the route I was thinking I'd need to go.

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