# Implementing full-page Screen-Only & Print-Only in PDF

I am interested in displaying some things (e.g.: title page) in full color on screen, while having the same object/page display in a black and white friendly form when printed.

According to this SO question, there is built-in functionality in the PDF specification for Screen-Only objects and Screen-And-Print objects. There may also be a way to add a layer on top of the B&W page that only displays the full color page on screen via the PDF 1.5 Optional Content Groups feature.

Similarly, this question demonstrates the selective printing of text via ocg-p. But it is not clear how I can use this package in the way that I need to.

My scenario is compounded by the fact that my color page text is white on a dark background.

### MWE:

This code presents the way I am currently switching back and forth between color and b&w. I change the printincolor bool variable to make the change.

\documentclass[11pt]{article}

\usepackage[demo]{graphicx}
\usepackage{etoolbox}

\providebool{printincolor}
% Will set color title page and section headings
\setbool{printincolor}{false}

% Setup color if needed
\ifbool{printincolor}{%
\usepackage[pagecolor=none]{pagecolor}%
\definecolor{MyBlue}{HTML}{1b3667}%
\usepackage{afterpage}}{}

\begin{document}

% Begin Title Page
{
\thispagestyle{empty}
\ifbool{printincolor}{%
\pagecolor{MyBlue}%
\afterpage{\nopagecolor}}{}
\begin{center}
{\ifbool{printincolor}{\color{white}\sffamily}{\sffamily}%  Set text color white or leave [default] black
\ifbool{printincolor}{\includegraphics[width=1.5in]{logo-gold}}{\includegraphics{logo-blue}}% put logo gold or blue
\\ \vskip 1in
\begin{huge}
\textbf{Title}
\vskip 0.1ex\rule{0.5\textwidth}{0.8pt}\vskip 1ex
Subtitle
\\
\end{huge}
\vfill\vfill
\begin{large}

Authors:\\
John Doe and Jane Doe\\
\end{large}
}
\end{center}
}

\end{document}


How can I layer (or otherwise display) two versions of the title page in a way that color displays on screen, but black and white is printed?

The solution I have come to (with many thanks to cfr and Steven B. Segletes for their answers to my related question) uses tikz to lay down a color layer, and then overlay that with a monochrome version that is only displayed when printing.

However, since the solution uses Optional Content Groups (package ocg-p), it does not have full support in all PDF viewers. Specifically, Adobe Reader is the only viewer that fully supports OCG, while many other (Apple's Preview, Skim and others) will fallback to the monochrome version (they simply show all layers on screen by default, not respecting the "print-only" or "initial state" flags). A few viewers (those based on poppler, i.e. primarily those in Linux) will degrade by only showing the color layer on screen and print (respecting the "initial state" flag, but not enabling the monochrome layer for print). So, bottom line is, Your Milage May Vary.

But, here is the solution nonetheless:

\documentclass[11pt]{article}

\usepackage[demo]{graphicx}
\usepackage{tikz} % Needed to draw titlepage elements
\usepackage{ocg-p} % For optional content groups

% Things to typeset on titlepage (since they are repeated twice
\newcommand{\titlematter}{%
\node [font={\huge\bfseries\sffamily}] at (.5\linewidth,-7) {Title};
\node [font={\huge\sffamily}] at (.5\linewidth,-10.625) {Subtitle};
\node [font={\large\sffamily}] at (.5\linewidth,-17) {Authors:\\ John Doe and Jane Doe};
\node (p) at (.25\linewidth,-9.00) {}; % nodes for line to connect later
\node (q) at (.75\linewidth,-9.00) {};
}

% Setup color if needed
\usepackage[pagecolor=none]{pagecolor}%
\definecolor{MyBlue}{HTML}{1b3667}%
\usepackage{afterpage}

\begin{document}

% Begin Title Page
{\thispagestyle{empty}%
\noindent
%% Color Version
\begin{tikzpicture}[overlay, remember picture, text=white, align=center]
\fill [fill=MyBlue] (current page.south west) rectangle (\paperwidth,\paperheight);
\node at (.5\linewidth,-2.125) {\includegraphics[width=1.5in]{logo-color}};
\titlematter
\draw [color=white](p) -- (q);
\end{tikzpicture}
%% Monochrome Version
\begin{ocg}[printocg=always]{MonochromeVersion}{monochrome}{0}
\begin{tikzpicture}[overlay, remember picture, text=black, align=center]
\fill [fill=white] (current page.south west) rectangle (\paperwidth,\paperheight);
\node at (.5\linewidth,-2.125) {\includegraphics[width=1.5in]{logo-monochrome}};
\titlematter
\draw (p) -- (q);
\end{tikzpicture}
\end{ocg}
%% Reset page color
\afterpage{\nopagecolor}%
\newpage
}

\end{document}


In Acrobat, this displays on screen in color:

And will print in the monochrome:

By choosing the layers tab in the side bar (placement may vary depending on viewer; some older versions of viewers don't have support for layers at all), you can optionally switch to the monochrome view on screen as well: