2

I want to "blank" a specified region of every page in a document. I thought of puting a blank image over that region of the document that I want hidden, but I don't know if this is possible.

I remember that the eso-pic package can insert background images to every page, but in my case I want the image to be on top of the text and hide it.

I need this only for printing (even if the text is still there, in the PDF file, behind the image -- that is not a problem).

Can this be done in LaTeX? Or there is need to process the final PDF file with some other software?

digital-Ink
  • 3,083

1 Answers1

1

This example places a gray box on top of the content at a specified position relative to the upper left corner on every page of the document using the atbegshi package.

As requested by the OP, the box is only printed on paper, but not shown in the viewer, provided a PDF specification conforming viewer, such as Acrobat Reader or Foxit, is used. Package ocgx2 is used to place the box on a print-only layer.

\documentclass{article}

% box color
\def\boxColor{lightgray}

% dimensions of the box
\def\boxWidth{0.25\paperwidth}
\def\boxHeight{0.25\paperwidth}

% position relative to upper left page corner
\def\boxOffsetX{0.3\paperwidth}
\def\boxOffsetY{0.3\paperheight}

\usepackage{atbegshi,xcolor}
\AtBeginShipout{%
  \AtBeginShipoutUpperLeftForeground{%
    \begin{ocg}[
      printocg=always,viewocg=never,
      showingui=never % also hide layer in the `Layers' navigation tab
    ]{veil}{veil}{false}%
      \hspace{\boxOffsetX}%
      \color{\boxColor}\raisebox{-\dimexpr\height+\boxOffsetY\relax}{\rule{\boxWidth}{\boxHeight}}%
    \end{ocg}%
  }%
}  

\usepackage{ocgx2} %PDF Layers
\usepackage{kantlipsum} % Bla bla

\begin{document}
\kant[1-10]
\end{document}
AlexG
  • 54,894
  • The gray box still appears in the Page Thumbnails in Adobe Acrobat Reader. Can this be changed? – digital-Ink Jan 17 '18 at 10:21
  • Seems to be an AR feature/bug. In Foxit, the box is hidden in the thumbnails as well. – AlexG Jan 17 '18 at 10:23
  • 1
    @digital-Ink : I could fix the code in order to hide the box in the thumbnails view in AR too by setting initial visibility to false. Not quite logical, but works. – AlexG Jan 18 '18 at 14:54