2

Thanks to another post I used

\usepackage{wallpaper}
\usepackage{watermark}
\leftwatermark{
    Left
    \ThisCenterWallPaper{1.0}{Wallpaper-L.pdf}
}
\rightwatermark{
    Right
    \ThisCenterWallPaper{1.0}{Wallpaper-R.pdf}
}

to have a full-sized pdf wallpaper on every page. I also discovered that ocgx2 supports XeLaTeX to create PDF layers, so now I wanted to put the wallpaper into a non-printing layer by surrounding \ThisCenterWallPaper with a \begin{ocg}[printocg=necer]{wallpaper}{wallpaper}{1} (and respective \end) as described here. Unfortunately, either wallpaper seems to "escape" the ocg environment, since the finished pdf has the layer but hiding it doesn't hide the wallpaper, nor does the print preview - the text, however, works.

I tried using other means to include the wallpaper, e.g. background's backgroundsetup with includegraphics, but that always resulted in a non-fullsize wallpaper (possibly due to my using geometry to modify the margins?).

In summary, I'm looking for means to include two pdf files as full-size, non-printing wallpapers (different ones for even and odd pages) in xetex...

1 Answer 1

2

This example uses packages ocgx2 (because of XeLaTeX), tikz and atbegshi in order to place non-printable watermarks into the background:

\documentclass[twoside,twocolumn]{article}

\usepackage{lipsum}
\usepackage{tikz}
\usepackage{atbegshi}
\usepackage{mwe}

\AtBeginShipout{%
  \AtBeginShipoutAddToBox{%
    \begin{ocg}[printocg=never,showingui=never]{watermark}{watermark}{on}%
    \begin{tikzpicture}[overlay,remember picture]
      \node [opacity=0.3] at (current page.center) {%
        \ifodd\thepage%
          \includegraphics[angle=90,width=\paperwidth,height=\paperheight]{example-image-a}%
        \else%                                                           
          \includegraphics[angle=90,width=\paperwidth,height=\paperheight]{example-image-b}%
        \fi%
      };
    \end{tikzpicture}%
    \end{ocg}%
  }%
}

\usepackage{ocgx2}

\begin{document}

\lipsum[1-29]

\end{document}
7
  • I've just seen that ocgx supports XeLaTeX as well.
    – AlexG
    Nov 26, 2015 at 16:00
  • Awesome, thanks! ocgx needs showingui replaced by listintoolbar though (untested), at least that's what ocgx2's README suggests at a quick glance. That also suggests using \usepackage[tikz]{ocgx2} (instead of the additional \usepackage{tikz}) Nov 27, 2015 at 9:55
  • 1
    [tikz] option is not necessary here. Actually, it replaces the \usetikzlibrary{ocgx} line, which, according to theocgx manual, enables some additional TikZ styles that can be used to associate TikZ scopes with OCGs, and to turn TikZ nodes into clickable buttons for changing OCG visibility. Read the ocgx manual for further details. In general, I recommend using ocgx2 since it extends the ocgx functionality and fixes some bugs inherited from the ocg-p package which ocgx loads under the hood.
    – AlexG
    Nov 27, 2015 at 10:30
  • There is probably no reason to not use ocgx2 indeed... Why did you choose opacity=0.3 by the way? Nov 27, 2015 at 10:50
  • 1
    As for opacity, I was thinking the background image would look more watermarkish that way. As for showframe, I would experiment with the loading order of the packages. As geometry also modifies the shipout routine via atbegshi, I would try loading geometry just before the document begins.
    – AlexG
    Nov 27, 2015 at 11:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .