This Java program adds a semi-transparent watermark to a PDF document using Qoppa’s library jPDFProcess.

You can change the watermark string, the font and size, the color, the location (x, y) and the rotation.

// Load PDF document
PDFDocument pdfDoc = new PDFDocument ("input.pdf", null);
// Font is Helvetica 64         
Font wmFont = PDFGraphics.HELVETICA.deriveFont(64f);
// Loop through all pages
for (int pageIx = 0; pageIx < pdfDoc.getPageCount(); ++pageIx)
 // Get the page
 PDFPage page = pdfDoc.getPage(pageIx);
 // Get a graphics object to draw onto the page
 Graphics2D g2d = page.createGraphics();
 // Draw watermark
 g2d.setColor (new Color (160, 160, 160, 160));
 g2d.translate(72, 72 + g2d.getFontMetrics().getAscent());
 g2d.drawString ("Confidential", 0, 0);
// Save the PDF document with watermarks
pdfDoc.saveDocument ("output.pdf");

Note: Helvetica® is a trademark Monotype Imaging Inc.