[Tex/LaTex] Create a copy of every page with a watermark

watermark

I often print letters with latex and I want to print every letter twice : once normal and once with a watermark ('COPY').

Is there any way to produce a single pdf file containing twice the letter, once with and once without the watermark as described ?

Until now, I did write the document in a file, say foo.tex and then imported it twice but it is not a good procedure (for reverse search for example)

\import{foo}
\newpage
\import{foo} --with some command for a watermark--

Best Answer

enter image description here

\documentclass[a4paper]{letter}
\newbox\shbox
\usepackage{graphicx,color}

\let\oldshipout\shipout
\def\shipout\vbox#1{%
\global\setbox\shbox\vbox{#1}%
\oldshipout\copy\shbox
\oldshipout\hbox{%
\rlap{\scalebox{25}{\rotatebox{50}{\color{red}Draft}}}%
\box\shbox}%
}
\begin{document}

\address{here\\or\\there}
\signature{me}

\begin{letter}{Someone}
\opening{Dear sir,}

\def\a{Stuff goes here. Stuff goes here. Stuff goes here. }
\def\b{1: \a\a 2: \a\a 3: \a\a 4: \a 5: \a\a 6: \a 7: \a}

\b\b

Red Green Blue: \b\ Yellow \b\b

One two three four \b.

\closing{The End}
\end{letter}

\end{document}