0

Is there a way to make some graphical elements to be non-printable, i.e. prints as white, while staying fully visible on screen?

Here's a MWE to play and have fun with:

\documentclass[11pt,letterpaper,twoside]{book}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
\usepackage{microtype}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{eso-pic}
\usepackage{xcolor}
\usepackage{showframe}

\newlength{\distance} \setlength{\distance}{0.0in} \newlength{\rulethickness} \setlength{\rulethickness}{0.5in} \newlength{\ruleheight} \setlength{\ruleheight}{\paperheight} \newlength{\xoffset} \newlength{\yoffset} \setlength{\yoffset}{0pt}

\AddToShipoutPicture{% \setlength\fboxsep{0pt}% \ifodd\value{page}% \setlength{\xoffset}{\distance}% \else \setlength{\xoffset}{\dimexpr\paperwidth-\rulethickness-\distance}% \fi \AtPageLowerLeft{% \put(\LenToUnit{\xoffset},\LenToUnit{\yoffset}){% \colorbox{lightgray}{\parbox[b][\ruleheight][c]{\rulethickness}{% \centering \ifodd\value{page}% \rotatebox[origin=cB]{90}{\color{red}{\large{\normalfont\textsc{Copyright notice}}}}% \else \rotatebox[origin=cB]{90}{\color{blue}{\huge{\normalfont\textsc{Some Title}}}}% \fi }}}}% }

\begin{document}

Test \newpage Another page

\end{document}

This code draws a gray vertical bar in the inner margins, with some copyright notice. I need it to stay visible while reading the PDF document on screen. But I would also like it to turn completely invisible when printed on paper. Is that possible with some LaTeX commands?


EDIT: Oups ! This question appears to be a duplicate of this one : Create element in pdf that doesn't print to paper

Cham
  • 2,304
  • Also, the accsupp package allows one thing to go to the visible layer and something else to go to the PDF data layer. For example, like this: https://tex.stackexchange.com/questions/241968/how-to-protect-a-word-from-finding-by-google-search-machines/388006#388006. However, this may not be exactly what you are looking for, as this is more for copy/paste protection. – Steven B. Segletes Mar 31 '21 at 22:00
  • The OCG method presented in the linked answer works only with a small set of PDF viewers: Acrobat Reader and Chrome PDF plugin. Another solution could be based on a non-printable PDF annotation which works with most other (or all?) PDF viewers too, such as Evince and Okular. – AlexG Apr 01 '21 at 08:00

1 Answers1

3

PDF Layers can be configured to not be printed on paper. This solution is used in the answer that was linked in the question. While this OCG-based method can be used with any typeset content, it is supported by only a small set of PDF viewers, namely Acrobat Reader and the Chromium PDF plugin.

For page elements that can be put in a box, as in the present question, another approach based on non-printable PDF annotations is possible. This method works with all known PDF viewers. With this approach, the optional page elements are shown as appearances of non-printable, non-interactive PDF annotations:

\documentclass[11pt,letterpaper,twoside]{book}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
\usepackage{microtype}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{eso-pic}
\usepackage{xcolor}
\usepackage{showframe}
\usepackage{graphicx}

\usepackage{pdfbase} \ExplSyntaxOn \let\tpPdfAnnot\pbs_pdfannot:nnnn\let\tpPdfLastAnn\pbs_pdflastann: \let\tpAppendToFields\pbs_appendtofields:n \def\tpPdfXform{\pbs_pdfxform:nnnnn{1}{1}{}{}} \let\tpPdfLastXform\pbs_pdflastxform: \ExplSyntaxOff

% odd \begin{lrbox}{0} \setlength\fboxsep{0pt}% \rotatebox{90}{% \colorbox{lightgray}{% \makebox[\paperheight][c]{% \raisebox{-0.5\totalheight+\depth}[0.25in][0.25in]{\large\scshape\color{red}Copyright notice}% }% }% } \end{lrbox} \tpPdfXform{0}\edef\oddElem{\tpPdfLastXform}

%even \begin{lrbox}{0} \setlength\fboxsep{0pt}% \rotatebox{90}{% \colorbox{lightgray}{% \makebox[\paperheight][c]{% \raisebox{-0.5\totalheight+\depth}[0.25in][0.25in]{\huge\scshape\color{blue}Some Title}% }% }% } \end{lrbox} \tpPdfXform{0}\edef\evenElem{\tpPdfLastXform}

\newlength\xoffset \AddToShipoutPicture{% \ifodd\value{page}% \setlength{\xoffset}{0pt}% \else \setlength{\xoffset}{\paperwidth-0.5in}% \fi \AtPageLowerLeft{% \put(\LenToUnit{\xoffset},0){% \tpPdfAnnot{0.5in}{\paperheight}{0pt}{% /Subtype/Widget/FT/Btn/T (elem.\value{page})% /AP<< \ifodd\value{page}% /N \oddElem % normal appearance \else /N \evenElem \fi >>% /Ff 65537 % non-interactive push button /F 0 % visible, but no-print }% \tpAppendToFields{\tpPdfLastAnn} }% }% }

\begin{document}

Test \newpage Another page

\end{document}

AlexG
  • 54,894