These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Attach a File as a Comment

ifb_techie
Registered: Nov 16 2007
Posts: 12

I'm trying to execute a menu item in acrobat 8 to "attach a file as a comment" using javascript behind a button.
 
I figured out the javascript that works is app.execMenuItem("Annots:Tool:FileAttachmentMenuItem") ;
 
When I test it with the debugger it works fine..however when I save it and test it in preview mode..it doesn't work. Any ideas? If it helps, I'm using a mac running OS X version 10.4.10
 
Thanks

My Product Information:
Acrobat Pro 8, Macintosh
lkassuba
ExpertTeam
Registered: Jun 28 2007
Posts: 3636
Hi ifb_techie,

The execution of a menu item from a PDF is restricted to a set of "safe" functions in Acrobat 8 for security reasons, which is why you cannot run the javascript. For more information on this visit Thom Parkers blog at:
[url=http://www.acrobatusers.com/blogs/thomp/?p=10]http://www.acrobatusers.com/blogs/thomp/?p=10[/url]

Thanks,
Lori

Lori Kassuba is an AUC Expert and Community Manager for AcrobatUsers.com.

ifb_techie
Registered: Nov 16 2007
Posts: 12
Hi Lori,

Thanks for you response. I am aware that Acrobat 8 has a set of safe functions for security reasons and have already read Thom Parkers blog you listed.

It is true that the menu function to attach a file has been restricted under the Document Menu item "Attach a File". However, commenting is not restricted and there is an option to attach a file as a comment...which works in an Acrobat Reader enabled form.

So my question basically is..if I can execute an action through the menu items, why can't I execute that same action through the use of a button?
lkassuba
ExpertTeam
Registered: Jun 28 2007
Posts: 3636
Hi ifb_techie,

Some the Javascript methods have security restrictions (i.e., Attach a File). Therefore, these methods can only be executed in a priviledged context (console, batch, and application initialization events). Other events, like mouse-up (your button) are considered non-priviledged. After Acrobat 7, menu items are also considered non-priviledged. Therefore to run them (menu items), you'll either need to change your Javascript preferences or execute the method through a trusted function. For more information on trusted function check out the Javascript for API Reference at:
[url=http://www.adobe.com/devnet/acrobat/pdfs/js_api_reference.pdf]http://www.adobe.com/devnet/acrobat/pdfs/js_api_reference.pdf[/url]

So in summary, you can't execute the your action through the use of a button (even though the same command may be on the menu when you reader-enable a PDF) because it is a security limitation of using javascript in Acrobat.

Lori

Lori Kassuba is an AUC Expert and Community Manager for AcrobatUsers.com.

ifb_techie
Registered: Nov 16 2007
Posts: 12
Hi Lori,

Thanks for your quick response. However, I have just one more question.

If I understand you correctly, can I therefore create my form using an older version of Acrobat Professional where these privilegesare still available? If so, will there be any incompatibilities with newer versions of Reader?
lkassuba
ExpertTeam
Registered: Jun 28 2007
Posts: 3636
Hi ifb_techie,

There will be compatibility issues with newer versions of Acrobat.
One other possibility open to you is to use the suggestion made by Thom Parker in this posting to attached files via a form field:
[url=http://www.acrobatusers.com/forums/ask_an_expert/questions/view/3626/]http://www.acrobatusers.com/forums/ask_an_expert/questions/view/3626/[/url]

FYI: In order to see the "Field is used for file selection" Option, you'll need to make sure that the only option you have selected is "Scroll Long Text" in the Options tab.

Hope this helps,
Lori

Lori Kassuba is an AUC Expert and Community Manager for AcrobatUsers.com.