I would like to add a sort of a watermark to a PDF file produced using LaTeX. I have in mind graphical elements (lines, circles, etc.) that would partially obscure the text on the page. The arrangement (and perhaps the shape and the number of) the elements should be different on every page, and it would be best if it could be derived from a pseudorandom seed given in the document, so different compilations would produce the same arrangement of elements.
As a bonus, I'd like to protect parts of the text from being obscured by those random lines and squiggles – instead of obscuring those parts, the watermarks could pass "under" a white rectangle with them on top, or just not appear where such protected text is. It's not a problem to mark such parts inside the LaTeX document.
My use case is a visible watermark for document tracking, with a very rudimentary anti-OCR feature (since some letters in the text would be obscured). Let me preemptively say that I am well aware of the ability to copy text from PDF, the possibility of retyping the document, etc.
Now the question is where to start looking for a solution – TikZ is able to draw geometric shapes pretty well, but I have no idea how to make them random and different on every page, nor how to protect parts of text… any pointers would be appreciated.
Best Answer
Here's a quick and dirty solution:
It is not very elegant, and especially the \dontobfuscate command is really very simple; it will work in horizontal mode (and generate a box, so it will be not breakable and the spaces will have their natural width, which will look ugly unless (a) only individual words are put in it or (b) the text is set ragged right or something similar; it will also work in math mode, but in a very primitive fashion (suitable for e.g. simple symbols). But it works as a proof of concept, and making it more versatile is now a question of some tweaking. Have fun!
PS. Not to mention that the "drm" tag might be considered a bit, say, offensive by some people in this community;).
Edit: as cjorssen mentioned in the comment, this needs two-pass compilation, since it uses the remember picture mechanism of tikz.