Rubber Stamp Annotations
- 3 minutes to read
You can use rubber stamp annotations to display predefined or custom stamps on a PDF page, such as to indicate a document’s status, review result, or workflow stage.
The PDF Document API supports the following stamp types:
- Built-in static stamps
- Built-in dynamic stamps
- Custom stamps
Create a Static Rubber Stamp
Create a RubberStampAnnotation object, specify its icon, and add the annotation to a page.
The following code snippet adds an Approved stamp to the first page:

package pdf;
import com.devexpress.docs.pdf.*;
import com.devexpress.system.drawing.*;
import java.nio.channels.*;
import java.nio.file.*;
import java.time.*;
public class Main {
public static void main(String[] args) throws Exception {
try (FileChannel fileChannel = FileChannel.open(Path.of("Document.pdf"));
PdfDocument pdfDocument = new PdfDocument(fileChannel)) {
Page page = pdfDocument.getPages().getFirst();
createRubberStampAnnotation(page);
// Save the document.
try (WritableByteChannel channel =
FileChannel.open(Path.of("Result.pdf"),
StandardOpenOption.CREATE,
StandardOpenOption.WRITE,
StandardOpenOption.TRUNCATE_EXISTING)) {
pdfDocument.save(channel);
}
}
}
static void createRubberStampAnnotation(Page page) {
RubberStampAnnotation stamp =
new RubberStampAnnotation(
new RectangleF(80, 510, 100, 24),
RubberStampAnnotationIconName.Approved);
// Specify annotation information.
stamp.setTitle("John Smith");
stamp.setSubject("Review");
stamp.setContent("Approved for publication.");
stamp.setCreationDate(OffsetDateTime.now());
page.getAnnotations().add(stamp);
}
}
The RubberStampAnnotationIconName class defines built-in stamp icons.
Create a Dynamic Rubber Stamp
Dynamic stamps display additional information, such as the title or creation date.
The PDF Document API supports the following dynamic stamp icons:
| Icon | Description | Preview |
|---|---|---|
DApproved |
Approved | ![]() |
DReviewed |
Reviewed | ![]() |
DRevised |
Revised | ![]() |
DConfidential |
Confidential | ![]() |
DReceived |
Received | ![]() |
The following code snippet creates a dynamic Reviewed stamp:

void createRubberStampDynamicAnnotation(Page page) {
RubberStampAnnotation stamp =
new RubberStampAnnotation(
new RectangleF(80, 510, 140, 30),
RubberStampAnnotationIconName.DReviewed);
// Specify annotation information.
stamp.setTitle("John Smith");
stamp.setSubject("Review");
stamp.setContent("Reviewed.");
stamp.setCreationDate(OffsetDateTime.now());
page.getAnnotations().add(stamp);
}
Create a Custom Stamp from a PDF Page
The PDF Document API accepts a PdfDocument, an InputStream, or a ReadableByteChannel as the source for a custom stamp.
The following code snippet creates a custom rubber stamp from the first page of a PDF document that contains a company-specific approval stamp:
import com.devexpress.docs.pdf.*;
import com.devexpress.system.drawing.*;
import java.io.*;
import java.nio.file.*;
public class Main {
public static void main(String[] args) throws Exception {
try (InputStream documentStream =
Files.newInputStream(Path.of("Invoice.pdf"));
InputStream stampStream =
Files.newInputStream(Path.of("CompanyApprovalStamp.pdf"))) {
PdfDocument pdfDocument = new PdfDocument(documentStream);
Page page = pdfDocument.getPages().getFirst();
// Create a rubber stamp annotation.
// Use the first page of the PDF document as the stamp appearance.
RubberStampAnnotation stamp =
new RubberStampAnnotation(
new RectangleF(50, 700, 180, 80),
stampStream, 0);
page.getAnnotations().add(stamp);
pdfDocument.save(Files.newOutputStream(Path.of("Invoice_Approved.pdf")));
}
}
}
If the source document is already loaded, use the corresponding overload:
PdfDocument stampDocument = new PdfDocument(
Files.newInputStream(Path.of("ApprovalStamp.pdf")));
RubberStampAnnotation stamp =
new RubberStampAnnotation(
new RectangleF(50, 700, 180, 80),
stampDocument);
stamp.setCustomIcon(stampDocument, 0);
page.getAnnotations().add(stamp);
Customize Stamp Information
Use markup annotation properties to specify additional information:
| Method | Description |
|---|---|
| setTitle() | Specifies the title (for example, the author name). |
| setSubject() | Specifies the annotation subject. |
| setContent() | Specifies the annotation text. |
| setCreationDate() | Specifies the creation date. |
| setColor() | Specifies the annotation color. |




