13

I'm looking for a solution to include a PDF background layer, which is not printed by default. I've seen that adobe seems to support a watermark layer, as discussed on graphicdesign.SE. I cannot test this method because I don't have access to these tools.

However, my understanding of a watermark is that it superimposed on the PDF document, whereas I want to have non printable background. I've tried \pagecolor, but it was printed using Adobe Acrobat on Windows.

I can always manually remove the background myself, but I want that a regular user who just prints my document doesn't print anything from the background. I'm assuming here that this user is using the bloated Acroread (aka Acrobat) PDF reader.

A related thread also links an example PDF which has a non-printable layer.

Here's MWE:

\documentclass[]{minimal}                                                   
\usepackage{xcolor}                                               
\definecolor{testcol}{cmyk}{0,0,0.1,0}                                      
\begin{document}                                                            
\pagecolor{testcol}                                                         
test                                                                        
\end{document}                                                              

I'm collecting tools and operating systems where the ocg-p method works (see examples in accepted answer). Please edit the question if you have experimented with a PDF viewer not listed.

Known to work

  • Adobe Reader 11.0.3, Windows: Layer visible on screen/printed: yes/no

Incomplete tests

  • Zathura 0.2.9-1 with mupdf backend, Linux: Layer visible/printed: yes/yes (rather: no/no)
    (Zathura does not support toggling visibility of individual layers. It displays + prints always all layers, whatever their setting regarding visibility + printability. This should better be described as 'no support for layers at all'. Tested with Zathura 0.3.7-1.)
  • Evince 3.12.1 (poppler backend 0.26.2-1 ), Linux: Layer visible/printed: yes/yes
    (Tested with Evince 3.22.1 / poppler backend 0.48.0. Layers may be individually toggled on/off for visibility. Evince prints all layers which are currently toggled as 'on'. Evince supports layer marking asking for 'never' to be printed.)
  • Preview.app, Mac: Layers visible/printed: yes/yes (rather: no/no)
    (Preview.app does not support toggling visibility of individual layers. It displays + prints always all layers, whatever their setting regarding visibility + printability. This should better be described as 'no support for layers at all'. Tested with Preview.app v9.0 (909.18) on macOS Sierra 10.12.6)
  • 1
    This could be done using Optional Content Groups (OCG), but support is sporadic at best across the wide range of PDF viewers. Several packages are of interest: ctan.org/ctan-portal/search/?phrase=ocg – Paul Gessler Jul 24 '14 at 15:29
  • it seems all of them are based on Asymptote. Coincidence? – Sebastian Jul 24 '14 at 15:37
  • ocg-p seems interesting and adds important information: OCGs are part of the PDF specification since version 1.5, OCGs are not part of the ISO standard 19005 PDF/A-1, but part of the newer PDF/A-2 standard. – Sebastian Jul 24 '14 at 15:42
  • @Kurt You, in your edit, say: Evince supports layer marking asking for 'never' to be printed. Does this mean that Evince follows the PDF spec in this regard finally? This would be good news, making ocgcolorlinks (pkg ocgx2) functional. – AlexG Dec 22 '18 at 18:19
  • 1
    @AlexG: I will re-test it as soon as I have an opportunity... – Kurt Pfeifle Dec 22 '18 at 20:10
12

Thanks to the comment of Paul Gessler, I found ocg-p, which does exactly what I need. Here is a demonstration of an unprintable colorbox:

\documentclass[]{minimal}
\usepackage{ocg-p}

\usepackage{xcolor}

\definecolor{testcol}{cmyk}{0,0,0.5,0}
\begin{document}
regular text
% \begin{ocg}{layer name}{layer id}{initial visibility}
\begin{ocg}[printocg=never]{Background}{1}{1}
  \colorbox{testcol}{text on Background layer}
\end{ocg}
regular text
\end{document}

I'm coping the explanation of the options from the manual:

manual screenshot

Indeed the text and the colorbox were not printed using standard Adobe Reader settings, but it was visible on the computer screen. Adobe Reader Version 11.0.3.

worked

On the topic of non-printable backgrounds, I found the following solution (compile thrice):

\documentclass[]{article}                                                   
\usepackage{ocg-p}                                                          
\usepackage{background}                                                     
\usepackage{xcolor}                                                         

\definecolor{testcol}{cmyk}{0,0,0.5,0}                                      
\backgroundsetup{%                                                          
scale=1,%                                                                   
angle=0,%                                                                   
opacity=1,%                                                                 
contents={%                                                                 
% \begin{ocg}{layer name}{layer id}{initial visibility}                     
\begin{ocg}[printocg=never]{Background}{1}{1}%                              
  \begin{tikzpicture}[remember picture,overlay]%     
   \path [fill=green!30] (current page.south west)rectangle (current page.north east);%
  \end{tikzpicture}%      
\end{ocg}}%                        
}                                                                           
\begin{document}                                                            
regular text                                                                
% \begin{ocg}{layer name}{layer id}{initial visibility}                     
\begin{ocg}[printocg=never]{Background}{1}{1}                               
  \colorbox{testcol}{text on Background layer}                              
\end{ocg}                                                                   
regular text                                                                
\end{document}                                                              
  • 1
    Pretty solid answer no need for CW. I'll ping the mods. – percusse Aug 13 '14 at 8:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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