How to Create a Menu Item to Invoke a PDF Document

In situations where you want a menu item to produce a PDF document (e.g., as in the case with the shortcuts.pdf card in NetBeans IDE), do the following:

  1. Switch to the Files window, create a top-level folder called 'release' in your module source structure, and put your PDF document there.

  2. Create an XML file with this content:
    <!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD PDF Document Menu Link 1.0//EN" 
        <idefile base="shortcuts"/>

    The above implies that the document will be named 'shortcuts.pdf' and that it will be found within the main folder of the module. If you put 'docs/shortcuts', for example, then the 'docs' folder of the module will be used instead. But then you would have to put the PDF in 'release/docs' instead.

  3. In your layer.xml file, register the above XML file, which in this case is called 'shortcuts.xml', as follows:
    <file name="shortcuts.xml" url="nbresloc:/com/me/bla/shortcuts.xml">
         <attr name="SystemFileSystem.localizingBundle" stringvalue=""/>
         <attr name="position" intvalue="480"/>

  4. In the Bundle referenced above, put the following:
    Menu/Help/shortcuts.xml=Keyboard Shortcuts

Thanks to this mail thread, I put the above steps together. Similarly, you can open a URL instead of a PDF from a menu item, following these instructions.


Post a Comment:
  • HTML Syntax: NOT allowed

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.


« March 2015