Have you ever thought that it would be nice to add some “floating text” to a PDF document that can be shown and hidden based on where the user’s mouse cursor is? This is useful, for example, if you want to provide some help for filling in a form field, or an explanation of a word on a page.
For the purpose of this post, let’s assume you want to explain one of more terms in your document with a popup dictionary entry when the user places the cursor over the word in question.
Adding a Tooltip
The first method is straight forward and only uses a button that does not have any function besides showing the tooltip that is associated with that button:
To accomplish this, open up the form editor (Tools>Forms>Edit) and then place a button on the document where you want to trigger the tooltip (e.g. around the word you want to explain).
Once the button is placed, double-click on the button on the document to bring up the full properties dialog for this form element (or right-click on the button and select “Properties” from the menu).
On the “General” tab provide a meaningful name (so that you can later recognize what this button is supposed to do), and add the tooltip you want to display:
On the “Appearance” tab set both border and fill colors to transparent:
And, as the last step, go to the Options tab and set “Layout” to “Label only”, and “Behavior” to “None”:
When you now exit form edit mode (or click on the Preview) button, you can move your mouse cursor over the (invisible to the user) button and after a second or two, you should see the tooltip being displayed.
This method does not give us much flexibility over the layout and the look of the “floating text”. By adding a text field that we can show and hide, we do have that control.
Show and Hide a Text Field
This method requires two fields: One text field that contains the text that should be shown when the mouse cursor is in a certain area, and a trigger field that is used to show and hide the text field.
To add a text field that we can show and hide, we start out just like with the tooltip method and we add a button – but this time without the tooltip text – to our document. In addition to the button, we also need to add a text field, which is done by picking the “Text Field” item form the “Add New Field” menu instead of the “Button” item.
Let’s first add the text to the floating text field and name it so that we can reference it.
To bring up the full properties for the text field, double-click on the text field (or right-click and select Properties from the menu). On the “General” tab, provide a meaningful name (e.g. FloatingText or FloatingText_1 if you want to use more than just one instance). Also, make this field “Read-Only” and “Hidden”:
Then go to the “Options” tab and provide the help text you want to add in the “Default value” field.
Now bring up the properties for your trigger button. Give the button a meaningful name on the “General” tab (e.g. TriggerButton – if you want to add more than just one floating element, you may want to call it TriggerButton_1). This time we are not filling in the tooltip field.
On the Appearance tab we have to set both the Border and Fill colors to transparent, just like before. The same goes for the “Options” tab, we need to set the “Layout” to “Label only”, and the “Behavior” to “None.
Here comes the important part – the section where we show and hide the floating text. Go to the Action tab and select to add a “Mouse Enter” action of “Show/Hide a field” and click on the “Add” button:
Now select your floating field by its name and select to “Show” it.
Repeat the same thing for a “Mouse Exit” event and “Hide” your floating field again.
That’s it. You can download my sample PDF file if you just want to see it work.
Once it’s working, you can of course modify the text, and adjust the font/fontsize/color/background color so that it fits your requirements.