addWatermarkText

fun addWatermarkText(pdf: ByteArray, text: String, fontSizePt: Float = 96.0f, color: PdfColor = PdfColor.LightGray, opacityFraction: Float = 0.3f, rotationDegrees: Float = 45.0f): ByteArray

Stamps diagonal watermark text across every page of pdf, centered, semi-transparent, and rotated.

The text is drawn in a Standard-14 Helvetica-Bold font (so nothing extra is embedded) into a content stream appended to each page, with an PDExtendedGraphicsState applying the constant alpha so the watermark sits over — but does not obscure — the existing content.

Return

the watermarked PDF bytes.

Parameters

pdf

the source PDF bytes.

text

the watermark text.

fontSizePt

watermark font size in PDF points; defaults to 96.

color

watermark fill color; defaults to a light gray.

opacityFraction

stroke/fill alpha in 0f..1f; defaults to 0.3.

rotationDegrees

counter-clockwise rotation of the text; defaults to 45 (bottom-left to top-right diagonal).