Stamp Geometry: Matrices, Rotation and Opacity
A watermark is drawn by wrapping the existing content in q/Q and appending a stream that sets text state and a transformation matrix [a b c d e f]. Translation chooses the anchor, rotation comes from cos and sin, and scaling changes the point size. PDF user space puts the origin at the bottom-left, so a top-right stamp needs the page height minus the text height, not a CSS-style top offset.
Opacity uses an ExtGState with /ca for fills and /CA for strokes, typically between 0.1 and 0.3; PDF 1.3 viewers ignore it and paint solid ink. Tiling repeats the stamp on a grid whose spacing is measured in points along the rotated axes. Centering requires the string width from the font /Widths array or a font library, otherwise proportional Latin and CJK text drift off-center.