Using the pdfcomment package to create an interactive tooltip when hovering over an image can be created with:


\pdftooltip{\includegraphics{img.png}}{This is the ALT text}

However this causes interference with my downstream PDF processor which adds another annotation onto this area. The tooltip catches mouse events and prevents expected operation.

If I use the [disable] option, the tooltip appears to be hidden, but actually the entire tooltip annotation object is absent from the PDF content stream.

Q: How can I use the pdftooltip, but set it to the 'hidden' state please?

I need it to be present in the PDF, but inactive and not catching any mouse events.

  • What is the use of a tooltip that does nothing? What are you trying to achieve? Have you seen the todonotes package? – Keks Dose Oct 23 '18 at 16:39
  • Keks, this hidden mode is needed for the purposes of a down-stream PDF consuming process, not what it looks like to a viewer. The consuming process identifies the rectangle layout of the tooltip object, and it's text value. Then it overlays a 3D annotation at the same position. Without the hidden mode, the tooltip object grabs the left mouse events and breaks the interaction in the 3D annotation. The work-flow is described at: pdf3d.com/latex-3d-pdf-placeholder-method along with sample test files. – user173052 Oct 23 '18 at 18:48

Here is a quick solution to your problem.

I have put together a modified pdfcomment.sty file, called pdfcomment1.sty. It has a new function pdftooltiphid, which produces tooltips in the same way as the original pdftooltip, but sets them to 'hidden'. You can call this function in the regular way:

\pdftooltiphid{\includegraphics{img.png}}{This is the ALT text}

In order to use the new pdfcomment1.sty file, I suggest you do the following:

  1. Locate your pdfcomment.sty file and rename it to 'pdfcomment_OLD.sty'. If you are wondering where to put the .sty file, or have trouble finding your other .sty files, take a look at this topic. And if you are using an online editor, such as Overleaf, see here.

  2. Rename the new pdfcomment1.sty file to 'pdfcomment.sty' and move it in the place of the old pdfcomment.sty.

  3. Restart your LaTeX editor.

That's it--you should now be able to use pdftooltiphid to create tooltips that are hidden by default.

The modified package does not change the functionality of the old pdfcomment, apart from adding the new function pdftooltiphid. However, it would be good to notify Josef Kleber, the author of pdfcomment, who would probably want to improve upon my quick solution.

  • 2
    Thank you Anton, your method works very well! I have checked the resulting PDF structure in Adobe Acrobat Pro Preflight analysis, verified the hidden mode is set as needed. – user173052 Oct 23 '18 at 18:41

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.