Tips & Tricks

Creating a Popup Menu

August 27, 2003


The Popup Menu has been around since Acrobat version 4 and has often been overlooked as a means to enable your users to get around your documents quickly or to activate Acrobat menu items or features.

To create a Popup Menu let's start by creating a form field button. Name the button something like 'menu' or 'popup'. Format the button so it has a border and a fill colour, set the Line Style to be 'Beveled'. In the 'Options' tab enter a meaningful label such as 'Menu' or 'Navigation'.

Under the Action tab select 'Run A Javascript' from the 'Select Action' dropdown box, now click the 'Add' button which should display the javascript editor dialog box.

The basic structure of the popup menu is as follows:

  1. Use the 'app' object to call the popup menu function: 'popUpMenu'
  2. Pass parameters to the function indicating:
  3. Menu Item Name, what get's displayed (cName)
  4. Whether or not the Menu item is a checkbox (bMarked: true/false)
  5. Is the menu item enabled or disabled? (bEnabled: true/false)
  6. A Sub Menu, which is created in the same fashion as a normal menu, this parameter is optional and only required if you want sub menus. (oSubMenu:{...})

If you paste the following code into the Javascript Editor, you'll get the following Popup Menu

var cChoice = app.popUpMenuEx
   {cName: "Item1", bMarked:true, bEnabled:false},
   {cName: "-"},
   {cName: "Item2", oSubMenu:
      [ {cName: "Item2 Sub1"},         
        {  cName: "Item2 Sub2", oSubMenu:
         {cName:"Item 2 Sub2 Subsub1", cReturn: "0"}
   {cName: "Item3"},
   {cName: "Item4", bMarked:true, cReturn: "1"}

As you can see the Menu Items in the popup menu have a direct relation to the example code we pasted above.

Something more meaninful could be to have the popup menu go to key pages in your document, for example you may have a Table of Contents page along with an Index or Glossary page. You could construct a Menu that showed the names of each of these sections and returned either the page number or named destination they appeared on.

For example, let's assume we have created named destinations for each of the sections in our document:

    Table of Contents: "toc"
    Index "index"
    Glossary "glossary"
    Help "help"

We also want to have a quick print function

var cChoice = app.popUpMenuEx
   	{cName: "Table of Contents",cReturn: "toc"},   
   	{cName: "-"},   
   	{cName: "Index",cReturn: "index"},   
   	{cName: "Glossary of Entries",cReturn: "glossary"},   
   	{cName: "Help Pages",cReturn: "help"},   
   	{cName: "Quick Print",cReturn: "qp"}   

if(cChoice != "qp" && cChoice != null)   
else if(cChoice != null)   

Copyright Dave Wraight & Planet PDF. No unauthorised reproduction, distribution or publication permitted.

PDF In-Depth Free Product Trials Ubiquitous PDF

Debenu Quick PDF Library

Get products to market faster with this amazing PDF developer SDK. Over 900 functions and an equally...

Download free demo

Five visions of a PDF Day

In the world of PDFs or as we like to say Planet (of) PDF, a year isn't a real PDF year without an intense few days of industry knowledge sharing.

May 15, 2018
Platinum Sponsor

Search Planet PDF
more searching options...
Planet PDF Newsletter
Most Popular Articles
Featured Product

Debenu PDF Aerialist

The ultimate plug-in for Adobe Acrobat. Advanced splitting, merging, stamping, bookmarking, and link control. Take Acrobat to the next level.


Adding a PDF Stamp Comment

OK, so you want to stamp your document. Maybe you need to give reviewers some advice about the document's status or sensitivity. This tip from author Ted Padova demonstrates how to add stamps with the Stamp Tool along with related comments.