Creating popup menus in Acrobat 8

Learn how to create popup menus that aid in document and page navigation similar to bookmarks.

By Ted Padova – February 27, 2007

 

In a previous article in this series on PDF interactivity, I talked about using bookmarks to navigate a collection of PDF files. In this article, I’ll discuss an alternative to bookmarks--popup menus that perform a similar task for document and page navigation.

You might have a small space available on a PDF document where it’s not possible to list a number of related links you want the end user to browse, or simply want to maximize the viewing area and keep the Bookmarks panel closed. In these cases, a popup menu with submenus can contain a number of links to pages or other files in a relatively small space. In Figure 1, you can see a popup menu I created for accessing other documents.

Figure 1.


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.

Popup menus in PDF packages

You can also create navigation links to pages within a PDF document using Named Destinations and by writing code similar to the previous script. Generally, bookmarks are used for page navigation more frequently than popup menus.

However, when working with PDF packages, you can’t create bookmarks on a document open in the Document pane that will appear in each file in the PDF package. All bookmarks are specific to the document where you create them. You can create duplicate bookmarks to view different files in the PDF package, but having a PDF package open with the PDF Package panel in view--and then having the Bookmarks panel open--reduces the Document pane to a smaller size, leaving little room for viewing document pages. A better solution is to create a button with a script to add a popup menu for navigating files. You can copy/paste the button on the pages for each package and collapse the PDF Package panel and the Bookmarks panel.

The following steps are used to create a popup menu when working with PDF packages:

1. Open the cover page in a PDF package and create a bookmark. (Note that you’ll need bookmarks created that will use the bookmark properties in the JavaScript you create).

2. Create an Action. After naming the bookmark, open the Bookmark Properties and click the Action tab. From the Select Action pull-down menu, choose Go to a page view and click the Add button. Selecting the action opens the Create Go to View dialog box, shown in Figure 2.

Figure 2.


3. Set the view. While the Create Go to view dialog box is open, click the document you want to view in the PDF packages panel. Click Set Link to set the link to the opening page in another document in the package. When you click the Set Link button, you return to the Actions tab, as shown in Figure 3.

Figure 3.


4. Click OK in the Actions tab. Note that you don’t need to worry about setting Window Preferences (as I discussed in a previous article). PDF package views are opened in the same window, regardless of what Window Preference option you use.

5. Create bookmarks for all documents in the PDF package. Repeat the same steps to create a bookmark that opens the first page of each PDF in the package. Keep in mind that the order of the bookmarks you create will be the same in your popup menu.

6. Create a button. Open the Forms tools and create a button field.

7. Add a JavaScript. Use the Run a JavaScript action type in the button field Properties dialog Actions tab. The following code creates a popup menu that opens two files in a PDF package:

var cRtn = app.popUpMenu("Lesson","Quiz");
if(cRtn != null){
	switch(cRtn) {
		case "Lesson":
			this.bookmarkRoot.children[0].execute();
			break;
		case "Quiz":
			this.bookmarkRoot.children[1].execute();
			break;
	}
}

The items “Lesson” and “Quiz” are the names of the bookmarks I used to open two other files in the PDF package. The code after case “Lesson” executes the properties of the first bookmark in the list of bookmarks in the Bookmarks panel: (bookmarkRoot[0]). The next item used for the quiz executes the properties for the second bookmark in the Bookmarks panel: (bookmarkRoot[1]). If you have additional bookmarks, they will follow in a logical order and each will have a sequential bookmarkRoot identifier.

8. Copy/paste the button. You can copy the button and paste it on other documents in the PDF Package, but you need to edit the code according to the bookmark names and sequence in the Bookmarks panel. Some minor editing in the JavaScript Editor will be necessary. If you want to duplicate the button so it appears on all pages in a PDF document, open a context menu on the button filed and select Duplicate. Specify the page range in the Duplicate Field dialog box.

Figure 4 shows a sample of the popup menu created using these steps.

Figure 4.

"Read more Acrobat 8 tips from Ted Padova in the "Adobe Acrobat 8 PDF Bible," available from Amazon."



Related topics:

JavaScript

Top Searches:


0 comments

Comments for this tutorial are now closed.

Comments for this tutorial are now closed.