Add Tooltip to Text

Add Tooltip to Searched Text by adding Invisible Button

It is often required to add some details for a phrase or specific word as a tooltip in the PDF document so that it can popup when the user hovers the mouse cursor over the text. Aspose.PDF for .NET provides this feature to create tooltips by adding an invisible button over the searched text. The following code snippet will show you the way to achieve this functionality:

Create a Hidden Text Block and Show it on Mouse Over

In Aspose.PDF, a feature to hide actions is implemented by which it is possible to show/hide text box field (or any other type of annotation) on mouse enter/exit over some invisible button. For this purpose, Aspose.Pdf.Annotations.HideAction Class is used to assign the action of hide/show to the text block. Please use the following code snippet to Show/Hide a Text Block on Mouse Enter/Exit.

Please also take into account that PDF actions in the documents work fine in the conforming readers (e.g. Adobe Reader) but no warranties for other PDF readers (e.g. web browser plugins). We have provided a brief investigation and found:

  • All implementations of the hide action in PDF documents work fine in Internet Explorer v.11.0.
  • All implementations of the hide action also work in Opera v.12.14, but we spot some response delay at the first opening of the document.
  • Only implementation using HideAction constructor accepting field name works if Google Chrome v.61.0 browses the document; Please use corresponding constructors if browsing in the Google Chrome is significant:


 buttonField.Actions.OnEnter = new HideAction(floatingField.FullName, false);

buttonField.Actions.OnExit = new HideAction(floatingField.FullName);

Any implementation of the hide action in PDF documents doesn’t work if Mozilla Firefox v.47.0 browses the document.