Tips & Tricks

Creating a Popup Menu

August 27, 2003

Advertisement
Advertisement
 

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)   
{   
   	this.gotoNamedDest(cChoice);   
}   
else if(cChoice != null)   
{   
   	this.print({bUI:false,bSilent:true});   
}   

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

Related Products at PDF Store

Nitro PDF Professional

Nitro PDF Professional, your PDF creation and editing product. Priced at $99, Nitro PDF Pro is the m... View full product details
Download free demo

ARTS PDF Aerialist

Take Acrobat to the next level with advanced splitting and merging; flexible bookmark creation and m... View full product details
Download free demo

ARTS PDF Crackerjack

Impose pages, automate your workflow, verify certified PDFs, print accurate colour separations, conv... View full product details
Download free demo

PDF In-Depth Free Product Trials Ubiquitous PDF

Nitro PDF Professional

the perfect PDF product for business and enterprise, combining an extremely competitive price with a...

Download free demo

XpdfViewer

This ActiveX control (OCX) provides a PDF file viewer component, enabling developers to add PDF viewing...

Download free demo

Ubiquitous PDF: PDF eBooks-Library

If you are looking for a good store of PDF content, you could do a lot worse than visiting eBooks-Library.com...

September 03, 2009
Search Planet PDF
more searching options...







Create PDF Free

Most Popluar Articles
Planet PDF Newsletter
Features

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.

Featured Product

Docmetrics

Generate more, higher-quality sales leads from your PDF marketing content. Docmetrics is a web-based system that lets you capture previously unavailable reader data. Free trial.

Platinum Sponsor
Create & Edit PDF - Nitro PDF Software

ARTS PDF

Silver Sponsors

PDF-Tools enfocus

QuickPDF: The Unrivaled PDF Developer Toolkit