A Java program that uses jPDFPrint to print a PDF document and adds a watermark on every page. We defined an interface called IWatermark that makes it easy for users to define and customize their own watermark, including text, font, color, location and orientation by simply using the well-known Graphics2D Java class.

// Load PDF document
PDFPrint pdfPrint = new PDFPrint("input.pdf", null);
// Create the watermark by implementing the IWatermark interface
IWatermark watermark = new IWatermark() {
 public void drawWatermark(Graphics2D g, int type, int pageIndex, int pageWidth, int pageHeight)
  // Watermark color (this can have transparency, but Java then makes the spool file very large)
  g.setColor(new Color(128, 128, 128));
  // Set the font
  g.setFont(new Font("sansserif", Font.PLAIN, 100));
  // Draw the watermark string, rotated 45 degrees
  g.drawString("Watermark", 150, g.getFontMetrics().getMaxDescent());
// Set the watermark on the document
// Print to default printer

Download Full Java Sample