Add Stamp to PDF

Add stamp to PDF

Use this workflow when an image-based stamp should be applied to the PDF.

Steps

  1. Create a PdfFileStamp instance and bind the source PDF.
  2. Create a Stamp object.
  3. Bind the stamp to an image file with bindImage.
  4. Add the stamp to the document with addStamp.
  5. Save the output and close the facade object.

Java example

public static void addStampToPdf(Path inputFile, Path imageFile, Path outputFile) {
    PdfFileStamp pdfStamper = new PdfFileStamp();
    try {
        pdfStamper.bindPdf(inputFile.toString());
        Stamp stamp = new Stamp();
        stamp.bindImage(imageFile.toString());
        pdfStamper.addStamp(stamp);
        pdfStamper.save(outputFile.toString());
    } finally {
        pdfStamper.close();
    }
}

The current PdfFileStampExamples.java class does not include a separate Java sample for text-only stamps, rotation, or opacity configuration.