9

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--
  • do you need the copies collating (possible but less convenient) or can you print out both 1st pages then both 2nd pages etc (easier) – David Carlisle Aug 31 '13 at 21:31
  • It is no problem if it is not collated. In practice, the (not duplicated) document will consist of 1 page. – Laurent Dudok de Wit Aug 31 '13 at 21:39
10

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}
  • What happens if the page contains hyperlinks? My guess is that it will lead to pdftex duplicate hyperlink warnings. – Aditya Aug 31 '13 at 23:52
  • @Aditya yes, but the question said print letter, so I assume it's aimed at a dead tree not the internet. – David Carlisle Sep 1 '13 at 0:36
  • Nice solution ! Do you know how to center the watermark ? – Laurent Dudok de Wit Sep 1 '13 at 7:45
  • 1
    @user81566 visual centre probably takes a bit of adjustment anyway so easiest is to replace \rlap{...} by \begin{picture}(0,0)\put(10,20){\scalebox...}\end{picture} then you can tune the (10,20) to put it anywhere on the page – David Carlisle Sep 1 '13 at 9:29
5

Here's one option using the pdfpages and background packages; your original.tex file looks something like

\documentclass{letter}
\usepackage[a6paper]{geometry}% just for the example
\usepackage{pdfpages}
\usepackage[some,contents=Copy]{background}
\usepackage{lipsum}

\signature{Your name}
\address{Street \\ City \\ Country}

\pagestyle{empty}

\begin{document}

\begin{letter}{Company name \\ Street\\ City\\ Country}
\opening{Dear Sir or Madam:}
\lipsum[4]\lipsum[4]
\closing{Yours Faithfully,}
\ps{P.S. Here goes your ps.}
\encl{Enclosures.}
\end{letter}

\includepdf[pages={-},pagecommand={\BgThispage\pagestyle{empty}},noautoscale]{copy.pdf}

\end{document}

I used the letter document class, but you can use any other of the more versatile classes around.

You first process the document commenting out the line:

\includepdf[pages={-},pagecommand={\BgThispage\pagestyle{empty}},noautoscale]{copy.pdf}

Then you copy the resulting PDF file to copy.pdf using (on Linux):

cp original.pdf copy.pdf

Then you uncomment out the line

\includepdf[pages={-},pagecommand={\BgThispage\pagestyle{empty}},noautoscale]{copy.pdf}

And reprocess original.tex.

An image of the result for the above example:

enter image description here

2

This is same as Gonzalo's, but some work reduced and every thing in one file as source.

Your actual letter is contained inside \begin{filecontents*} and \end{filecontents*}

%% compile this with --shell-escape option enabled. i.e., pdflatex --shell-escape mainletter
%%-----mainletter.tex-----
\documentclass{article}
\usepackage{filecontents}
\usepackage[some,contents=Copy]{background}
\usepackage{pdfpages}
\begin{filecontents*}{letter.tex}                              %% actual letter starts
  %
  \documentclass{letter}
  \usepackage[a6paper]{geometry}% just for the example
  %\usepackage[some,contents=Copy]{background}
  \usepackage{lipsum}
  %
  \signature{Your name}
  \address{Street \\ City \\ Country}
  %
  \pagestyle{empty}
  %
  \begin{document}
  %
  \begin{letter}{Company name \\ Street\\ City\\ Country}
  \opening{Dear Sir or Madam:}
  \lipsum[4]\lipsum[4]
  \closing{Yours Faithfully,}
  \ps{P.S. Here goes your ps.}
  \encl{Enclosures.}
  \end{letter}
  \end{document}
  %  
  \end{filecontents*}                             %% actual letter ends
%
\immediate\write18{pdflatex letter}
%
\begin{document}
  %% comment first line if you want if you want two pdf file-- letter.pdf and mainletter.pdf. If you want them collated, then don't comment.
  \includepdf[pages={-},pagecommand={\pagestyle{empty}},noautoscale]{letter.pdf}
  \includepdf[pages={-},pagecommand={\BgThispage\pagestyle{empty}},noautoscale]{letter.pdf}
\end{document}

This will give you two pdf files - letter.pdf and mainletter.pdf. letter.pdf is your letter and mainletter.pdf will contain the copy with watermark, if you comment out the first line (as indicated in code). If you want them collated, then both lines may be left as such.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.