Adding stamp annotations to a PDF document
Use stamp annotations to mark document state in PDF workflows.
Common use cases include:
- Approval and rejection workflows
- Draft and final document marking
- Confidentiality labeling
- Quality control and review tracking
In this guide, you’ll add:
- Default and custom stamp styles
- Color-customized stamps
- Multiple status stamps on one page
How Nutrient helps
Nutrient .NET SDK handles stamp annotation structures and appearance generation.
The SDK handles:
- Stamp annotation dictionaries and icon rendering
- Stamp appearance streams and text positioning
- Stamp style resources and icon loading
- Appearance state and color transformations
Complete implementation
This example adds several stamp annotations to a PDF file:
using Nutrient;Working with stamp annotations
Open the document with using statements(opens in a new tab) so resources are cleaned up after processing.
Then:
- Create a PDF editor.
- Get the page collection.
- Add a letter-size page (
612 × 792) if the document is empty. - Get the annotation collection from the first page.
try{ using Document document = Document.Open("input.pdf"); using PdfEditor editor = PdfEditor.Edit(document); PdfPageCollection pages = editor.PageCollection;
if (pages.Count == 0) { pages.Add(612.0f, 792.0f); }
PdfPage page = pages.First ?? throw new InvalidOperationException("The document has no pages."); PdfAnnotationCollection annotations = page.AnnotationCollection;Adding a basic stamp
Add a stamp with AddStamp(x, y, width, height, title, 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.
This sample:
- Adds a stamp at
(400, 600). - Sets the stamp style to
PdfRubberStampIcon.ApprovedwithStampStyle. - Sets the color to green with
Color.FromArgb(255, 0, 128, 0).
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.StampStyle = PdfRubberStampIcon.Approved; approvedStamp.Color = Color.FromArgb(255, 0, 128, 0);Adding a confidential stamp
Add a confidentiality stamp and set its icon style.
This sample sets:
- The position to
(400, 500). - The stamp style to
PdfRubberStampIcon.Confidential.
The stamp keeps the default red color unless you set a different color:
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.StampStyle = PdfRubberStampIcon.Confidential;Other available stamp types
Use other PdfRubberStampIcon values to represent more states.
This sample adds:
- A
NotApprovedstamp at(50, 700). - A
Finalstamp at(50, 600)with the color blue (ARGB 255, 0, 0, 255).
// Not Approved stamp PdfStampAnnotation notApprovedStamp = annotations.AddStamp( 50.0f, 700.0f, 150.0f, 50.0f, // x, y, width, height "Reviewer", "Rejected" ); notApprovedStamp.StampStyle = PdfRubberStampIcon.NotApproved;
// Final stamp PdfStampAnnotation finalStamp = annotations.AddStamp( 50.0f, 600.0f, 150.0f, 50.0f, // x, y, width, height "Legal", "Final version" ); finalStamp.StampStyle = PdfRubberStampIcon.Final; finalStamp.Color = Color.FromArgb(255, 0, 0, 255);Saving the document
Save the output PDF.
The catch block catches NutrientException if processing fails:
editor.SaveAs("output.pdf"); Console.WriteLine("Successfully saved output.pdf");}catch (NutrientException e){ Console.Error.WriteLine($"Error: {e.Message}"); Environment.Exit(1);}Conclusion
Use this workflow to add stamp annotations:
- Open the document with
usingstatements for automatic resource cleanup. - Create an editor and access the page collection.
- Ensure at least one page exists by adding a letter-size page if needed.
- Retrieve the annotation collection for the target page.
- Add basic stamp annotations with the default
Draftstyle and red color. - Customize stamp styles using
StampStylewithPdfRubberStampIconenumeration values. - Customize stamp colors using the
Colorproperty with ARGB color values. - Add
Approvedstamps with green color for approval workflows. - Add
Confidentialstamps for marking sensitive documents. - Add
NotApprovedstamps for rejection indicators. - Add
Finalstamps to mark completed documents. - Save the document — the
usingstatements release the native handles.
For related annotation workflows, refer to the .NET SDK annotation guides.