# Display text in PDF, but remove it when physically printing the document

I'm trying to create a document which contains some special text that's only visible when the document is opened in, e.g., Acrobat. When printing it using a normal printer, I want the text to be removed (or maybe just white-colored). Does anyone here know a way to do so?

Short example:

...
\begin{document}
Hello, this is an example.\\
\printInvisible{This is not visible when printed.}
\end{document}


should give a PDF with this content

Hello, this is an example.
This is not visible when printed.


but lead to the following paper-printed document

Hello, this is an example.


Thank you so much for helping me out!

Best,

Chris

• see the ocgx2 package. It allows you to add layers. – Ulrike Fischer May 18 at 12:31

Found a solution to the problem.

It was necessary to load the ocg-p package before hyperref. The following code (assuming standard document class etc.) worked for me:

...
\usepackage{ocg-p,hyperref}
\begin{document}
This text is always visible

\begin{ocg}[printocg=never]{layername}{layerid1}{on}
This text is visible in view mode, and it is removed when printing.
\end{ocg}
\end{document}