Imagine that you want to simulate a hand stamp on every page in some large documents. It must be an imperfect print, with random page-to-page variations in ink intensity, fading, rotation and blur. Imagine also that stamp content must change with each document.

The traditional solution would be to buy rubber stamps for each document and make stamping and scanning exercises, but besides being expensive, what fun would it be?

A cheaper solution is to insert a PNG or PDF image in every page at some place, but designing each stamp is still a lot of previous work. Moreover, it will be too obviously computer-generated if the stamp is always the same image in the same place on every page, even when the original is a very realistic stamp.

In How to make a realistic old rubber stamp? it is shown that stamps could include LaTeX text and how a fading effect could mimic in part a rubber stamp. Beyond this, I am trying to make the whole stamp in LaTeX (excepting some inner image too complex for coding), with easily configurable content and ink color and with some noise in circle lines, with the help of TikZ library decorations.pathmorphing, transparencies, and text layers. The result is the above image and below dirty slow-witted code.

I find this still a very poor result. Not only because an expert could make a more realistic blur and/or cleaner code and/or faster compilation, but mainly because while thinking what would be a good general purpose LaTeX stamper, I thought of several minimal requirements:

  • pdflatex compatible
  • Highly configurable by a end user (user-defined text contents, ink color, size, central coat of arms)
  • Result compatible with usual PDF viewers (not only Acrobat Reader)
  • Random page-to-page stamp rotation (probably best limited around +/- 30 degrees)
  • Random page-to-page fading. Probably a simple fading of the whole stamp with random orientation (360 degrees) is enough, but it must not affect the overlapping text.
  • Random page-to-page ink intensity (i.e., whole transparency between 0.5 to 0.8)
  • Random page-to-page position between a concrete area (i.e, around +/- 2 cm in the x,y position of page)

Unfortunately I still have very little experience to improve the code significantly, mainly with TikZ. Is this all possible?

Finally, what could be your own desired milestone for a hypothetical stamper package? Making alternate stamps oval or rectangular shapes, for example?

My apologies for the broad question but I think that in this case even a partial answer could be more manageable than a storm of complete answers to isolated problems.



\definecolor{stampink}{RGB}{0 34 85}           % Define color old stamp in RGB 
\newcommand\textUp{TOWARD A STAMPER PACKAGE}   % Top label
\newcommand\textDown{Open question}            % Bottom label
\newcommand\textCap{\texttt{\bfseries\today}}                    % Center label
% PDF (name and path) for best result with same RGB that stampink

% free hand style of circles stolen from https://tex.stackexchange.com/a/49272/11604
\pgfdeclaredecoration{free hand}{start}
  \state{start}[width = +1pt,
                next state=step,
                persistent precomputation = \pgfdecoratepathhascornersfalse]{}
  \state{step}[auto end on length    = 3pt, % 3
               auto corner on length = 3pt, % 3               
               width=+1pt] % 1
      {\pgfpoint{rand*.25pt}{rand*.2pt}} % good values .2pt aand .15pt
 \tikzset{free hand/.style={
    decoration={free hand}
\def\freedraw#1;{\draw[free hand] #1;} 


\newcommand\Stamper{\resizebox{3cm}{3cm}{ % FINAL SIZE TAMP
\begin{tikzpicture}[opacity=.8,transparency group]
\freedraw[color=stampink,opacity=.3,line width=5pt,rotate=0] (0,0.02) circle (3.6cm);
\freedraw[color=stampink,opacity=.5,line width=3pt,rotate=30] (0,0.01) circle (3.6cm);
\freedraw[color=stampink,opacity=.7,very thick,rotate=20] (0,0) circle (3.6cm);
\path [opacity=.2,postaction={decorate,decoration={raise=-1.3ex,text along path, 
reverse path,text align=center,
text={|\huge\bfseries\color{stampink}|\textUp}}}] (-31:3.055cm) arc (-31:210:3.055cm);
\path [opacity=.4,postaction={decorate,decoration={raise=-1.7ex,text along path, 
reverse path,text align=center,
text={|\huge\bfseries\color{stampink}|\textUp}}}] (-30.7:3.055cm) arc (-30.7:210:3.055cm);
\path [opacity=.8,postaction={decorate,decoration={raise=-1.5ex,text along path, 
reverse path,text align=center,
text={|\huge\bfseries\color{stampink}|\textUp}}}] (-30:3.05cm) arc (-30:210:3.05cm);
\path [opacity=.2,postaction={decorate,decoration={raise=-1.2ex,text along path, text align=center,
text={|\huge\bfseries\color{stampink}|\textDown}}}] (210:3.05cm) arc (210:330:3.05cm);
\path [opacity=.4,postaction={decorate,decoration={raise=-.85ex,text along path, text align=center,
text={|\huge\bfseries\color{stampink}|\textDown}}}] (210:3.05cm) arc (210:330:3.05cm);
\path [opacity=.8,postaction={decorate,decoration={raise=-1ex,text along path, text align=center,
text={|\huge\bfseries\color{stampink}|\textDown}}}] (210:3.05cm) arc (210:330:3.05cm);
\freedraw[color=stampink,opacity=.3,line width=4pt,rotate=0] (0.015,0.02) circle (2.5cm) node[scale=1.54] (m) {\textCenter}; 
\freedraw[color=stampink,opacity=.5,line width=3pt,rotate=30] (-0.025,-0.01) circle (2.5cm) node[scale=1.5] (m) {\textCenter}; 
\freedraw[color=stampink,opacity=.7,very thick,rotate=20] (0,0) circle (2.5cm) node[scale=1.52] (m) {\textCenter}; 
    [postaction={path fading=north,fill=white!99,opacity=0.6}]
    (-5,-5) rectangle (5,5);%



% stamp under text

% stamp over text


Edit: As stampcoat.pdf cannot be uploaded, the MWE is changed to include a PNG version:


This can be changed with any PDF or PNG image with transparent background and the same RGB that the stampink defined color.

  • @Kundor Thanks for the edit. Much better now!
    – Fran
    Feb 4 '13 at 3:55
  • Did you read up about implementing packages in general? It seems to me that adding the requirement that the package should implement stamps makes it difficult to see the difference between the drawing-specific parts of the implementation and the package interface-specific part of the implementation. As a result, the answers you get will become very specific and won't be of much help to others.
    – user10274
    Feb 4 '13 at 13:03
  • 1
    @MarcvanDongen Indeed, the first step is not make the package, but I figured it was important explain the whole set of problems and the ultimate goal to obtain answers in the right direction. We'll see. Anyway it is useful to see if a stamper package is really interesting.
    – Fran
    Feb 5 '13 at 2:02
  • i) It would be much easier just to create a random position generator, which would look already really realistic. ii) In addition, you can rotate about a small random angle. iii) Finally, you can simply change the total intensity of your drawing. This is not so difficult for images created internally with tikz or similar as you exchange colors by lighter ones, e.g. \color{stampink!20!white} and exchange the value 20 with another random variable.
    – strpeter
    Feb 11 '13 at 22:52
  • 1
    @cfr It is still on the to-do list.
    – Fran
    Aug 5 '16 at 4:36

You could adapt the following example:

contents={\begin{tikzpicture}\draw(0,0)circle(1)node{A \thepage B};\end{tikzpicture}},


If you want it randomised, you have to replace the computations in the code by appropriate computations using a randomizer. The most difficult aspect would be the color, because the color definition isn't parsed by tikz (or so, I haven't quite understood that technique). If you need more complicated computations for example for the color, you could also employ the everypage package, that is used by background package anyway.


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.