This article demonstrates how to add tooltip to the text on an existing PDF document in C#. Spire.PDF for .NET supports to create tooltips by adding invisible button over the searched text from the PDF file.
Step 1: Load the sample document file.
PdfDocument doc = new PdfDocument();
doc.LoadFromFile("Sample.pdf");
Step 2: Searched the text “Add tooltip to PDF” from the first page of the sample document and get the position of it.
PdfPageBase page = doc.Pages[0];
PdfTextFind[] result = page.FindText("Add tooltip to PDF").Finds;
RectangleF rec = result[0].Bounds;
Step 3: Create invisible button on text position
PdfButtonField field1 = new PdfButtonField(page, "field1"); field1.Bounds = rec;
Step 4: Set the content and format for the tooltip field.
field1.ToolTip = "E-iceblue Co. Ltd., a vendor of .NET, Java and WPF development components"; field1.BorderWidth = 0; field1.BackColor = Color.Transparent; field1.ForeColor = Color.Transparent; field1.LayoutMode = PdfButtonLayoutMode.IconOnly; field1.IconLayout.IsFitBounds = true;
Step 5: Save the document to file.
doc.SaveToFile("Addtooltip.pdf", FileFormat.PDF);
Effective screenshot after adding the tooltip to PDF:

using Spire.Pdf;
using Spire.Pdf.Fields;
using Spire.Pdf.General.Find;
using System.Drawing;
namespace TooltipPDF
{
class Program
{
static void Main(string[] args)
{
PdfDocument doc = new PdfDocument();
doc.LoadFromFile("Sample.pdf");
PdfPageBase page = doc.Pages[0];
PdfTextFind[] result = page.FindText("Add tooltip to PDF").Finds;
RectangleF rec = result[0].Bounds;
PdfButtonField field1 = new PdfButtonField(page, "field1");
field1.Bounds = rec;
field1.ToolTip = "E-iceblue Co. Ltd., a vendor of .NET, Java and WPF development components";
field1.BorderWidth = 0;
field1.BackColor = Color.Transparent;
field1.ForeColor = Color.Transparent;
field1.LayoutMode = PdfButtonLayoutMode.IconOnly;
field1.IconLayout.IsFitBounds = true;
doc.SaveToFile("Addtooltip.pdf", FileFormat.PDF);
}
}
}
