0

I saved a web page as a pdf.

I would like to add watermark to this existing pdf.

I googled and got an approach that suggest to merge 2 pdf, the original one and the one contains watermark.

this code could used to generate a watermark pdf

\documentclass{beamer}
\usepackage[printwatermark]{xwatermark}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{lipsum}

\newsavebox\mybox
\newwatermark*[
  allpages,
  angle=45,
  scale=6,
  xpos=-20,
  ypos=15
]{\usebox\mybox}

\begin{document}

\savebox\mybox{\tikz[color=red,opacity=0.3]\node{DRAFT};}

ab

\end{document}

although there have to be some additional characters ("ab" in this case).

is it possible use latex to generate a pdf that only contains watermark without any other additional characters?

3
  • 1
    Replace ab by ~, for instance.
    – user194703
    Nov 17, 2019 at 4:59
  • 1
    @Schrödinger'scat Thanks a lot! Please move your comments to answer, I'll accept it.
    – JJJohn
    Nov 17, 2019 at 5:07
  • 1
    I think if your problem is solved, all is fine. What I want to say is that I will be happy to write an answer if you think that will be useful for others, but if you only want to solve the issue then I may not. BTW, you do not need to load graphicx nor xcolor here, and probably want to add \setbeamertemplate{navigation symbols}{}` to remove the navigation symbols on the bottom right.
    – user194703
    Nov 17, 2019 at 5:26

1 Answer 1

3

The following code overlays pages 3 and 4 of the pdfpages manual with a red "DRAFT" watermark:

\documentclass{article}
\usepackage{tikz}
\usepackage{pdfpages}
\pagestyle{empty}
\newcommand{\filename}{/usr/local/texlive/2018/texmf-dist/doc/latex/pdfpages/pdfpages.pdf}
\newcommand{\watermark}{\tikz[remember picture, overlay] \node [red,opacity=0.3,rotate=45,scale=15.0] at (current page.center) {DRAFT};}
\begin{document}
\includepdf[pages=3-4,pagecommand={\watermark}]{\filename}
\end{document}

enter image description here

I use the pdfpages package and its macro \includepdf to include an external PDF file:

  • The mandatory argument takes the filename of the external file. In this example, I use the absolute path of the pdfpages manual. You can replace this by the name of your PDF file, and give the relative path instead - i.e. just the filename if the PDF is in the same folder as the LaTeX file.
  • The optional argument pages takes the range of pages of the PDF to be included in the output file.
  • The optional argument pagecommand takes some code to be executed on top of each page. Here, I use tikz to overlay the included pages of the PDF with the word "DRAFT" in red, semi-transparent, rotated, and scaled to a large size. Adjust this as needed.

This is not exactly an answer to the question as stated, but I think it answers the issue you want to achieve if we also consider what you wrote in the other question which we just closed as a duplicate.

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.