RubberStampAnnotation Class
Defines a PDF rubber stamp annotation.
Declaration
public class RubberStampAnnotation extends MarkupAnnotation
Remarks
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
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);
}
}
Refer to the following help topic for additional information: Rubber Stamp Annotations.
Inherited Members
Inheritance
Constructors
RubberStampAnnotation(RectangleF bounds, InputStream documentStream, int pageIndex) Constructor
Initializes a new instance of the RubberStampAnnotation class with specified bounds, document stream, and page index.
Declaration
public RubberStampAnnotation(RectangleF bounds, InputStream documentStream, int pageIndex)
Parameters
| Name | Type | Description |
|---|---|---|
| bounds | RectangleF | The rubber stamp annotation bounds. |
| documentStream | InputStream | The stream that contains the PDF document used to generate the stamp. |
| pageIndex | int | The zero-based index of the document page that contains the stamp. |
RubberStampAnnotation(RectangleF bounds, InputStream documentStream) Constructor
Initializes a new instance of the RubberStampAnnotation class with specified bounds and document stream.
Declaration
public RubberStampAnnotation(RectangleF bounds, InputStream documentStream)
Parameters
| Name | Type | Description |
|---|---|---|
| bounds | RectangleF | The rubber stamp annotation bounds. |
| documentStream | InputStream | The stream that contains the PDF document used to generate the stamp. |
Remarks
If you created the annotation with the RubberStampAnnotation(RectangleF, InputStream) constructor, do not pass the same stream to setCustomIcon(). The constructor already applies the custom icon and consumes the stream. Use a new stream or reset the stream position before calling this method.
RubberStampAnnotation(RectangleF bounds, Page page) Constructor
Initializes a new instance of the RubberStampAnnotation class with specified settings.
Declaration
public RubberStampAnnotation(RectangleF bounds, Page page)
Parameters
| Name | Type | Description |
|---|---|---|
| bounds | RectangleF | The rubber stamp annotation bounds. |
| page | Page | The page that contains the stamp. |
RubberStampAnnotation(RectangleF bounds, PdfDocument document, int pageIndex) Constructor
Initializes a new instance of the RubberStampAnnotation class with specified bounds, PDF document, and page index.
Declaration
public RubberStampAnnotation(RectangleF bounds, PdfDocument document, int pageIndex)
Parameters
| Name | Type | Description |
|---|---|---|
| bounds | RectangleF | The rubber stamp annotation bounds. |
| document | PdfDocument | The PDF document used to generate the stamp. |
| pageIndex | int | The zero-based index of the document page that contains the stamp. |
RubberStampAnnotation(RectangleF bounds, PdfDocument document) Constructor
Initializes a new instance of the RubberStampAnnotation class with specified stamp bounds and PDF document.
Declaration
public RubberStampAnnotation(RectangleF bounds, PdfDocument document)
Parameters
| Name | Type | Description |
|---|---|---|
| bounds | RectangleF | The rubber stamp annotation bounds. |
| document | PdfDocument | The PDF document used to generate the stamp. |
RubberStampAnnotation(RectangleF bounds, ReadableByteChannel documentStream, int pageIndex) Constructor
Initializes a new instance of the RubberStampAnnotation class with specified stamp bounds, channel, and page index.
Declaration
public RubberStampAnnotation(RectangleF bounds, ReadableByteChannel documentStream, int pageIndex)
Parameters
| Name | Type | Description |
|---|---|---|
| bounds | RectangleF | The rubber stamp annotation bounds. |
| documentStream | ReadableByteChannel | The PDF document channel that contains the stamp. |
| pageIndex | int | The zero-based index of the document page that contains the stamp. |
RubberStampAnnotation(RectangleF bounds, ReadableByteChannel documentStream) Constructor
Initializes a new instance of the RubberStampAnnotation class with specified stamp bounds and channel.
Declaration
public RubberStampAnnotation(RectangleF bounds, ReadableByteChannel documentStream)
Parameters
| Name | Type | Description |
|---|---|---|
| bounds | RectangleF | The rubber stamp annotation bounds. |
| documentStream | ReadableByteChannel | The channel that contains the PDF document used to generate the stamp. |
RubberStampAnnotation(RectangleF bounds, RubberStampAnnotationIconName iconName) Constructor
Initializes a new instance of the RubberStampAnnotation class with specified bounds and rubber stamp annotation icon name.
Declaration
public RubberStampAnnotation(RectangleF bounds, RubberStampAnnotationIconName iconName)
Parameters
| Name | Type | Description |
|---|---|---|
| bounds | RectangleF | The rubber stamp annotation bounds. |
| iconName | RubberStampAnnotationIconName | The rubber stamp annotation icon name. |
Methods
getIconName() Method
Returns the rubber stamp annotation icon name.
Declaration
public RubberStampAnnotationIconName getIconName()
Returns
| Type | Description |
|---|---|
| RubberStampAnnotationIconName | The rubber stamp annotation icon name. |
setCustomIcon(InputStream stream, int pageIndex) Method
Sets a custom icon for the rubber stamp annotation from the specified PDF document stream.
Declaration
public void setCustomIcon(InputStream stream, int pageIndex)
Parameters
| Name | Type | Description |
|---|---|---|
| stream | InputStream | The PDF document stream. |
| pageIndex | int | The zero-based index of the document page that contains the content used as the custom icon. |
setCustomIcon(Page page) Method
Sets a custom icon for the rubber stamp annotation from the specified page.
Declaration
public void setCustomIcon(Page page)
Parameters
| Name | Type | Description |
|---|---|---|
| page | Page | The page that contains the content used as the custom icon. |
Remarks
Refer to the following help topic for additional information: Create a Custom Stamp from a PDF Page.
setCustomIcon(PdfDocument document, int pageIndex) Method
Sets a custom icon for the rubber stamp annotation from the specified PDF document.
Declaration
public void setCustomIcon(PdfDocument document, int pageIndex)
Parameters
| Name | Type | Description |
|---|---|---|
| document | PdfDocument | The PDF document. |
| pageIndex | int | The zero-based index of the document page that contains the content used as the custom icon. |
setCustomIcon(ReadableByteChannel stream, int pageIndex) Method
Sets a custom icon for the rubber stamp annotation from the specified PDF document channel.
Declaration
public void setCustomIcon(ReadableByteChannel stream, int pageIndex)
Parameters
| Name | Type | Description |
|---|---|---|
| stream | ReadableByteChannel | The PDF document channel. |
| pageIndex | int | The zero-based index of the document page that contains the content used as the custom icon. |
Remarks
If you created the annotation with the RubberStampAnnotation(RectangleF, ReadableByteChannel) constructor, do not pass the same stream to setCustomIcon(). The constructor already applies the custom icon and consumes the stream. Use a new stream or reset the stream position before calling this method.
setIconName(RubberStampAnnotationIconName value) Method
Sets the rubber stamp annotation icon name.
Declaration
public void setIconName(RubberStampAnnotationIconName value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | RubberStampAnnotationIconName | The rubber stamp annotation icon name. |
Remarks
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);
}
Refer to the following help topic for additional information: Rubber Stamp Annotations.




