This article describes how to add a tooltip in PDF using Python. It has all the details to set the IDE, a list of steps, and a sample code to insert the PDF mouseover popup text using Python. In this article, we will work with the TextBox; you may add tooltips to other controls as well, if required.
Steps to Add PDF Tooltip using Python
- Set the environment to use Aspose.PDF for Python via .NET to add a tooltip
- Import the required classes and modules from the aspose.pdf library
- Apply the license for watermark-free output
- Create an empty PDF file, add a page, and define a Rectangle area for displaying the tooltip
- Create a TextBox and set its parameters
- Set the alternate_name property for adding a tooltip
- Set the border and appearance parameters before adding the TextBox to the form
- Save the resultant PDF file on the disk
These steps summarize how to work with PDF hover text. Import the necessary classes and modules, apply the license, create or load a PDF file and add a page if empty, define a rectangle to display the TextBox with a tooltip, and set its appearance. Finally, add this control to the form in the PDF and save the output on the disk.
Code for Adding PDF Tooltip using Python
This code demonstrates the process of adding a tooltip to a TextBox. Note that you may use the alternate_name property wherever available in the other controls supported by this library for adding a tooltip. Similarly, tooltips can be added in annotations also using different features such as subject, contents, or title.
This article has taught us about the tooltips in a PDF file. To remove highlights in a PDF file, refer to the article Remove Highlight from PDF using Python.