
我感興趣的是在螢幕上以全彩顯示一些內容(例如:標題頁),同時在列印時以黑白友好的形式顯示相同的物件/頁面。
根據這個問題,PDF 規格中有針對僅螢幕物件和螢幕並列印物件的內建功能。可能還有一種方法可以在黑白頁面頂部添加一個圖層,僅透過 PDF 1.5 在螢幕上顯示全彩頁面選用內容組特徵。
相似地,這個問題演示通過 選擇性打印文字ocg-p
。但目前尚不清楚如何以我需要的方式使用這個包。
我的彩色頁面文字在深色背景上為白色,這一事實使我的情況變得更加複雜。
微量元素:
這段程式碼展示了我目前在彩色和黑白之間來回切換的方式。我更改printincolor
bool 變數來進行更改。
\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}
如何以螢幕上顯示彩色但列印黑白的方式分層(或以其他方式顯示)標題頁的兩個版本?
答案1
我找到的解決方案(非常感謝CFR和史蒂文·B·塞格萊斯他們對我的回答相關問題)用於tikz
放置彩色圖層,然後用僅在列印時顯示的單色版本覆蓋該圖層。
但是,由於該解決方案使用可選內容組(包ocg-p
),因此並非所有 PDF 檢視器都完全支援。具體來說,Adobe Reader 是唯一完全支援OCG 的檢視器,而許多其他檢視器(Apple 的Preview、Skim 等)將回退到單色版本(預設情況下它們只是在螢幕上顯示所有圖層,而不尊重「僅列印」或「初始狀態」標誌)。一些檢視器(基於poppler 的檢視器,即主要是Linux 中的檢視器)將透過僅在螢幕上顯示彩色圖層並列印(尊重「初始狀態」標誌,但不啟用單色圖層進行列印)來降低效能。所以,最重要的是,您的里程可能會有所不同。
但是,這裡仍然有解決方案:
\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}
在 Acrobat 中,它以彩色顯示在螢幕上:
並將以單色列印:
透過選擇側欄中的「圖層」標籤(位置可能會因檢視器而異;某些舊版本的檢視器完全不支援圖層),您也可以選擇切換到螢幕上的單色視圖: