title: In PDFBox, Is it possible to add a tooltip (hint) to a mark annotation?
body: <p><strong>In a Nutshell</strong></p>
  
  <p>I've been working on a program that gets a pdf, highlights some words (via pdfbox Mark Annotation obj) and saves the new pdf.</p>
  
  <p>I'd like my highlighted words to show a tooltip with some small description on it, like a hint.</p>
  
  <p>For instance, I want that on my pdf, the highlighted word <em>activated</em> shows the tooltip <em>important word found</em> when I stop the mouse over it.</p>
  
  <p><a href="https://pdfhost.io/v/4wwNIO1Q_Oncogenic_BRAF_Induces_Melanoma_Cell_Invasion_by_Downregulating_the_cGMPSpecific_Phosphodiesterase_PDE5A.pdf" rel="nofollow noreferrer">This</a> is the original test pdf.</p>
  
  <p><strong>My Code</strong></p>
  
  <p>With a couple of abstractions, in a nutshell, I have:</p>
  
  <pre><code>File file = new File("path/to/myfile/mypdf.pdf");
  
  PDDocument document = PDDocument.load(file);
  
  PDPage page = document.getPage(0);
  List&lt;PDAnnotation&gt; annotations = page.getAnnotations();
  
  PDAnnotationTextMarkup txtMark = new PDAnnotationTextMarkup(PDAnnotationTextMarkup.SUB_TYPE_HIGHLIGHT);
  txtMark.setRectangle(pdRectangle);
  txtMark.setQuadPoints(quadPoints);
  txtMark.setColor(getColor());
  
  annotations.add(txtMark);
  </code></pre>
  
  <p><strong>Current Result</strong></p>
  
  <p>Currently it generates a pdf with mark annotations like below on the word <em>activated</em>:</p>
  
  <p><a href="https://i.stack.imgur.com/g18XN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/g18XN.png" alt="enter image description here"></a></p>
  
  <p><strong>What I Want</strong></p>
  
  <p>Now I want to add a tooltip on it, just like I have when I add a hyperlink, like showed below, but with a free text instead. I can only have a tooltip like this if this is attached to a url, even if I added the string I need, pdfbox would internally create a uri out of it...</p>
  
  <p><a href="https://i.stack.imgur.com/Nhrs5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Nhrs5.png" alt="enter image description here"></a></p>
  
  <p>FYI: this is the annotation link code:</p>
  
  <pre><code>PDAnnotationLink link = new PDAnnotationLink();
  link.setAction("www.stackoverflow.com");
  link.setRectangle(pdRectangle);
  link.setQuadPoints(quads); annotations.add(link);
  </code></pre>
  
  <p><strong>What I've Tried and Why I'm Not Satisfied Yet</strong></p>
  
  <p>1) I've tried to add an annotation link, as showed above, but with a description instead of a url, like <em>important word found</em>. The result isn't good, the tooltip is transformed to something like: <em>file:///Users/myproject/root/important word found</em>. </p>
  
  <p>Also this link annotation is not the recommended way to go since in some cases I will want to have both a URL and a Tooltip. But if I could turn it around, it would be a real consideration.</p>
  
  <p>2) I've tried to add a content to my mark annotation, which works like a popup, like showed below:</p>
  
  <p><a href="https://i.stack.imgur.com/bnU9O.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bnU9O.png" alt="enter image description here"></a></p>
  
  <p>It works... when I mouse over it, my tooltip description shows up beautifully. However, you can see that bubble icon just above the word. That's the only problem with this solution, these bubbles are quite annoying and end up overlapping important part of the text and polluting the pdf. If I could hide them or something I'd be satisfied too.</p>
  
  <p><a href="https://pdfhost.io/v/SwVulx2S_Oncogenic_BRAF_Induces_Melanoma_Cell_Invasion_by_Downregulating_the_cGMPSpecific_Phosphodiesterase_PDE5A.pdf" rel="nofollow noreferrer">here</a> is the doc with this annotation.</p>
  
  <p>And the code to add this popup was simple adding the line below:</p>
  
  <pre><code>txtMark.setContents("Important word found");
  </code></pre>
  
  <p><strong>Conclusion</strong></p>
  
  <p>Any tip to either add a tooltip nicely or remove that annotation bubble will be hugely appreciated. Thanks in advance.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>As @Tilman Hausherr suggested on comments, I've added the following line to my code:</p>
  
  <pre><code>txtMark.setTitlePopup("Important word found");
  </code></pre>
  
  <p>Without setting the content. I don't have the annoying bubble anymore, but now I need to double click my annotation and a not much good looking or practical popup shows up:</p>
  
  <p><a href="https://i.stack.imgur.com/HYVP0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HYVP0.png" alt="enter image description here"></a></p>
  
  <p>This helps a little bit since it's the best I got so far.</p>
  
  <p><strong>EDIT 2</strong></p>
  
  <p>My attempt with PDAnnotationPopup: added to my code the lines below, as suggested by @Tilman:</p>
  
  <pre><code>...
  PDAnnotationPopup pdAnnotationPopup = new PDAnnotationPopup();
  pdAnnotationPopup.setParent(txtMark);
  pdAnnotationPopup.setContents("Important word found");
  
  // Just to make sure
  pdAnnotationPopup.setInvisible(false);
  pdAnnotationPopup.setNoView(false);
  pdAnnotationPopup.setNoZoom(false);
  pdAnnotationPopup.setLocked(false);
  pdAnnotationPopup.setHidden(false);
  
  annotations.add(pdAnnotationPopup);
  </code></pre>
  
  <p>I also explored other PDAnnotationPopup parameters such as <em>setOpen</em>, <em>setRectangle</em>... and tried to keep it coexisting with <em>txtMark.setTitlePopup</em>.</p>
  
  <p>Unfortunately none of that affected my code in any way. Only when I set <em>setOpen(true)</em> plus setRectangle I could see something: a completely empty popup over each of my text mark annotations.</p>