Use stamp annotations to mark document status in PDF workflows.

Common use cases include:

  • Approval and rejection workflows
  • Draft and final state marking
  • Confidentiality labeling
  • Review tracking across document stages

In this guide, you’ll add:

  • Default and custom stamp styles
  • Color-customized stamps
  • Multiple status stamps on one page
Download sample

How Nutrient helps

Nutrient Java SDK handles stamp annotation structures and appearance generation.

The SDK handles:

  • Parsing stamp annotation dictionaries and rubber stamp icon rendering
  • Managing predefined stamp appearance streams and text positioning
  • Handling stamp style enumeration and icon resource loading
  • Complex annotation appearance states and color transformations

Complete implementation

This example adds multiple stamp annotations to a PDF:

package io.nutrient.Sample;
import io.nutrient.sdk.Document;
import io.nutrient.sdk.types.Color;
import io.nutrient.sdk.editors.PdfEditor;
import io.nutrient.sdk.editors.pdf.pages.PdfPageCollection;
import io.nutrient.sdk.editors.pdf.pages.PdfPage;
import io.nutrient.sdk.editors.pdf.annotations.PdfAnnotationCollection;
import io.nutrient.sdk.editors.pdf.annotations.PdfStampAnnotation;
import io.nutrient.sdk.enums.PdfRubberStampIcon;
public class StampAnnotations {

Create the main method as the sample entry point:

public static void main(String[] args) {

Working with stamp annotations

Open the document with try-with-resources, create an editor, and ensure one page exists:

try (Document document = Document.open("input.pdf")) {
PdfEditor editor = PdfEditor.edit(document);
PdfPageCollection pages = editor.getPageCollection();
if (pages.getCount() == 0) {
pages.add(612.0f, 792.0f);
}
PdfPage page = pages.getFirst();
PdfAnnotationCollection annotations = page.getAnnotationCollection();

Adding a basic stamp

Add a stamp with addStamp(x, y, width, height, author, contents).

In this sample:

  • The position is (400, 700).
  • The size is 150 × 50.
  • The default style is Draft.
  • The default color is red (ARGB 255, 255, 0, 0).
PdfStampAnnotation draftStamp = annotations.addStamp(
400.0f, 700.0f, 150.0f, 50.0f, // x, y, width, height
"Author",
"Work in progress"
);

Adding an approved stamp

Add a second stamp and customize its style.

In this sample:

  • The position is (400, 600).
  • setStampStyle(PdfRubberStampIcon.Approved) sets the approved icon.
  • setColor(...) sets the green color.
PdfStampAnnotation approvedStamp = annotations.addStamp(
400.0f, 600.0f, 150.0f, 50.0f, // x, y, width, height
"Approver Name",
"Document approved on review"
);
// Customize the stamp appearance
approvedStamp.setStampStyle(PdfRubberStampIcon.Approved);
approvedStamp.setColor(Color.fromArgb(255, 0, 128, 0));

Adding a confidential stamp

Add a confidentiality stamp and set its icon style.

In this sample:

  • The position is (400, 500).
  • setStampStyle(PdfRubberStampIcon.Confidential) applies the confidential icon.
  • The default red color remains unless changed.
PdfStampAnnotation confidentialStamp = annotations.addStamp(
400.0f, 500.0f, 150.0f, 50.0f, // x, y, width, height
"Security Officer",
"Contains sensitive information"
);
// Customize the stamp appearance
confidentialStamp.setStampStyle(PdfRubberStampIcon.Confidential);

Other available stamp types

Use other PdfRubberStampIcon values to represent additional states.

This sample adds:

  • A NotApproved stamp at (50, 700).
  • A Final stamp at (50, 600) with the color blue.
// Not Approved stamp
PdfStampAnnotation notApprovedStamp = annotations.addStamp(
50.0f, 700.0f, 150.0f, 50.0f, // x, y, width, height
"Reviewer",
"Rejected"
);
notApprovedStamp.setStampStyle(PdfRubberStampIcon.NotApproved);
// Final stamp
PdfStampAnnotation finalStamp = annotations.addStamp(
50.0f, 600.0f, 150.0f, 50.0f, // x, y, width, height
"Legal",
"Final version"
);
finalStamp.setStampStyle(PdfRubberStampIcon.Final);
finalStamp.setColor(Color.fromArgb(255, 0, 0, 255));

Saving the document

Save the output PDF and close the editor:

editor.saveAs("output.pdf");
editor.close();
} catch (Exception e) {
System.err.println("Error: " + e.getMessage());
e.printStackTrace();
}
}
}

Conclusion

Use this workflow to add stamp annotations:

  1. Open the document and create an editor.
  2. Access the page collection and ensure at least one page exists.
  3. Retrieve the annotation collection for the target page.
  4. Add basic stamp annotations with the default Draft style and red color.
  5. Customize stamp styles using setStampStyle() with PdfRubberStampIcon enumeration values.
  6. Customize stamp colors using setColor() with ARGB color values.
  7. Add Approved stamps with green color for approval workflows.
  8. Add Confidential stamps for marking sensitive documents.
  9. Add NotApproved stamps for rejection indicators.
  10. Add Final stamps to mark completed documents.
  11. Save and close the editor.

For related annotation workflows, refer to the Java SDK guides.