The TeX FAQ

Frequently Asked Question List for TeX

Formatting

Watermarks on every page

It’s often useful to place some text (such as “DRAFT”) in the background of every page of a document. For LaTeX users, the simplest way to do this uses the draftcopy package. This can deal with many types of DVI processors (in the same way that the graphics package does) and knows translations for the word “DRAFT” into a wide range of languages (though you can choose your own word, too). Unfortunately, however, the package relies on PostScript specials, and will therefore fail if you are viewing your document with xdvi, and won’t even compile if you’re using pdfLaTeX. (pdfLaTeX users need one of the other solutions below.)

The wallpaper package builds on eso-pic (see below). Apart from the single-image backdrops described above (“wallpapers”, of course, to this package), the package provides facilities for tiling images. All its commands come in pairs: one for “general” use, and one applying to the current page only.

The draftwatermark package uses the same author’s everypage package to provide a simple interface for adding textual (“DRAFT”-like) watermarks.

The xwatermark package provides very flexible watermarking, with a “modern” (key-value) interface.

More elaborate watermarks may be achieved using the eso-pic package, or by using everypage (see below). Eso-pic attaches a picture environment to every page as it is shipped out; the user can put things into that environment: the package provides commands for placing things at certain useful points (like “text upper left” or “text center”) in the picture, but the user is at liberty to do what he or she likes.

Eso-pic is, in turn, built upon the package atbegshi. That package has the capability to produce watermarks on top of the other material on the page; this doesn’t sound very “watermark-like”, but can be useful on pages where the watermark would otherwise be hidden by graphics or the like. The atbegshi command that eso-pic uses is \AtBeginShipoutUpperLeft; \AtBeginShipoutUpperLeftForeground is what’s needed instead to place the material on top of the rest of the content of the page.

Everypage allows you to add “something” to every page, or to a particular page; you therefore need to construct your own apparatus for anything complicated.

Finally, one can use the pdftk untility; with it, the command:

pdftk a.pdf background b.pdf output c.pdf

will recreate a.pdf as c.pdf, having used the first page of b.pdf as background on every page. If you have a standard background (“DRAFT” or “SECRET”, or whatever) used in several files, pdftk might well be attractive.

Pdftk is available as a command line tool; it is available in most linux distritbutions, but may be downloaded from its home site

FAQ ID: Q-watermark
Tags: layout