Skip to main content
Participating Frequently
June 13, 2017
Answered

Using hyperlinks to non pdf files in a popup menu

  • June 13, 2017
  • 3 replies
  • 1661 views

I am not educated at all in javascript so I need the expertise of someone here to help me please!!!

I came across this page on the old Adobe Forum pages - https://acrobatusers.com/tutorials/popup-menus-part-i

This sort of popup menu is exactly what I need.  But I need it to work so that when someone clicks on the choice it either opens a Word document or a webpage.  The Word doc would ideally be an attachment to the PDF.  But if that isn't possible then it could be located in the same folder as the PDF. 

The code for the popup menu only works on PDF's saved in the same folder.  How do I make it work for Word doc's and URL's?

The above link says:

This menu is designed to open PDF documents within a common folder. Note that you’ll want your host document and supporting documents all copied to the same folder. To create a popup menu that opens other documents, add a Button field and then add a Run JavaScript action in the Actions tab. When you click the Add button in the Actions tab, enter the following Acrobat JavaScript code:

var cChoice = app.popUpMenu( ["Human Resources", "eeoAnalysis.pdf", "employeeData.pdf"], ["Customer Forms", "customerID.pdf", "orderForm.pdf", "purchaseOrder.pdf", "corporateOrder.pdf"], ["Employee Forms", "employeeApplication.pdf", "performanceEvaluation.pdf", ] ); app.openDoc((cChoice), this); 

Each line within the brackets is a different root menu item. The text appearing within the first quotations marks is a menu title and the remaining text within each set of quotes defines the filenames I want to open when accessing the submenu command. The last line of code instructs Acrobat to open the file selected from a selected menu command.

This topic has been closed for replies.
Correct answer try67

- Launch an attached Word file:

this.exportDataObject({cName: "My Document.doc", nLaunch: 2});

- Launch a URL:

app.launchURL("http://www.google.com");

3 replies

cyndi2966Author
Participating Frequently
June 13, 2017

try67 I really appreciate your help. 

And I am going to ask for more.

This is the code for the popup menu.  Could you please insert those bits of code in the right places for me in the code below for the popup menu?

Please make the "eeoAnalysis.pdf" say google.com and open the web page and make the "employeeData.pdf" piece say mydocument.com and open the document.

Just ignore the rest and leave it as is.  If I can get those two links to work - then I can do the rest.

var cChoice = app.popUpMenu( ["Human Resources", "eeoAnalysis.pdf", "employeeData.pdf"], ["Customer Forms", "customerID.pdf", "orderForm.pdf", "purchaseOrder.pdf", "corporateOrder.pdf"], ["Employee Forms", "employeeApplication.pdf", "performanceEvaluation.pdf", ] ); app.openDoc((cChoice), this); 
try67
Community Expert
Community Expert
June 13, 2017

That's not so easily done... There needs to be a way of identifying what type of action to perform by each selection. It can be based on the actual value itself but if that's not possible you would need to either hard-code it or switch to using popUpMenuEx and use a unique return value that identifies both the type of action to perform as well as the action "parameter" (file name/attachment file name/URL/etc.)

If you're interested I can write for you the full code that will do that for a small fee. You can contact me privately (try6767 at gmail.com) to discuss it further.

Joel Geraci
Community Expert
Community Expert
June 13, 2017

It could actually be done with one call. First you'd check if the selected item has the same name as an existing attachment and if so, launch it, if not, go to the URL.

cyndi2966Author
Participating Frequently
June 13, 2017

Okay.  If the Word doc is an attachment - how would I code that into the code I inserted in my original post?

Same goes for opening a URL?  Let's use google.com as the example URL.

I need it to work in this drop down menu please???

Joel Geraci
Community Expert
Community Expert
June 13, 2017

There are examples of how to export and launch an attachment here...

Acrobat DC SDK Documentation

try67
Community Expert
Community Expert
June 13, 2017

Launching an external file that isn't a PDF: Not possible.

Launching a website: Possible, using the launchURL method of the app object.

Joel Geraci
Community Expert
Community Expert
June 13, 2017

If the Word document is an attachment, it can be launched.

try67
Community Expert
Community Expert
June 13, 2017

Yes, that's true... I should have mentioned that attachments can be opened, just not independent files.