Skip to main content
All docs
V25.1
  • PdfRubberStampAnnotationFacade Class

    Contains members used to manage rubber stamp annotations without access to their inner structure.

    Namespace: DevExpress.Pdf

    Assembly: DevExpress.Pdf.v25.1.Core.dll

    NuGet Package: DevExpress.Pdf.Core

    Declaration

    public class PdfRubberStampAnnotationFacade :
        PdfMarkupAnnotationFacade

    Remarks

    Create Rubber Stamp Annotations

    The following code snippet creates a Top Secret rubber stamp:

    rubber stamp

    using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
    {
        // Load a document
        processor.LoadDocument("..\\..\\Document.pdf");
    
        // Access the first page properties
        PdfPageFacade page = processor.DocumentFacade.Pages[0];
    
        // Define a rubber stamp rectangle
        PdfRectangle rubberStampRectangle = new PdfRectangle(663, 526, 763, 576);
    
        // Create a rubber stamp in this rectangle
        PdfRubberStampAnnotationFacade rubberStamp =
           page.AddRubberStampAnnotation(rubberStampRectangle, PdfRubberStampAnnotationIconName.TopSecret);
        rubberStamp.Author = "Jesse Faden";
        rubberStamp.Contents = "Made in PDF Document API";
    }
    

    Create a Dynamic Rubber Stamp

    Specify one of the following icon names as the PdfPageFacade.AddRubberStampAnnotation method parameter to create a dynamic rubber stamp:

    Icon Name Rubber Stamp
    DReviewed reviewed
    DRevised reviewed
    DApproved approved
    DConfidential confidential
    DReceived received

    Use the Author and ModificationDate properties to specify the author and the date displayed in the rubber stamp.

    The following code snippet creates a Reviewed dynamic stamp:

    using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
    {
        // Load a document
        processor.LoadDocument("..\\..\\Document.pdf");
    
        // Access the first page's properties
        PdfPageFacade page = processor.DocumentFacade.Pages[0];
    
        // Define a rubber stamp rectangle
        PdfRectangle rubberStampRectangle = new PdfRectangle(663, 526, 763, 576);
    
        // Create a "Top Secret" rubber stamp annotation
        PdfRubberStampAnnotationFacade rubberStamp =
           page.AddRubberStampAnnotation(rubberStampRectangle, PdfRubberStampAnnotationIconName.DReviewed);
        rubberStamp.Author = "Jesse Faden";
    }
    

    Create an Annotation with a Custom Stamp

    You can generate a stamp from another document’s page. Pass the path to a file and a page number as the PdfPageFacade.AddRubberStampAnnotation method parameters to create a custom stamp.

    The following code snippet generates a custom stamp from another document:

    custom stamp

    using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
    {
        // Load a document
        processor.LoadDocument("..\\..\\Document.pdf");
    
        // Access the first page's properties
        PdfPageFacade page = processor.DocumentFacade.Pages[0];
    
        // Define a a rubber stamp rectangle
        PdfRectangle rubberStampRectangle = new PdfRectangle(663, 526, 763, 576);
    
        // Specify a document to use as a custom stamp
        string customStampFile = "..\\..\\Demo.pdf";
    
        // Create a rubber stamp annotation
        PdfRubberStampAnnotationFacade rubberStamp =
           page.AddRubberStampAnnotation(rubberStampRectangle, customStampFile, 2);
        rubberStamp.Author = "Jesse Faden";
    
        // Save the result
        processor.SaveDocument("..\..\Result.pdf")
    
    }
    

    Edit Rubber Stamp Annotations

    The PdfPageFacade.Annotations property returns all page annotation properties. You can filter rubber stamp annotation properties, cast them to the PdfRubberStampAnnotationFacade class, and use class properties to modify annotation parameters.

    The following code snippet retrieves all rubber stamps, and changes their icon and author:

    using DevExpress.Pdf;
    using System.Linq;
    
    using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
    {
        // Load a document
        processor.LoadDocument("..\\..\\Document.pdf");
    
        // Access the first page's properties
        PdfPageFacade page = processor.DocumentFacade.Pages[0];
    
        // Retrieve all rubber stamp annotations
        var rubberStamps = page.Annotations.Where
          (annotation => annotation.Type == PdfAnnotationType.RubberStamp);
    
        // Change rubber stamp parameters
        foreach (PdfRubberStampAnnotationFacade rubberStamp in rubberStamps) 
        {
            rubberStamp.Author = "Brian Zetc";
            rubberStamp.IconName = PdfRubberStampAnnotationIconName.Confidential;
            rubberStamp.Opacity = 0.5;
        }
    
    }
    

    Flatten Rubber Stamp Annotations

    Call one of the following methods to flatten an annotation:

    Method Description
    PdfDocumentFacade.FlattenAnnotations Flattens document annotations.
    PdfPageFacade.FlattenAnnotations Flattens annotations of a specific page.
    PdfAnnotationFacade.Flatten() Flattens a specific annotation.

    The following code snippet flattens all rubber stamp annotations on the first page.

    using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
    {
        // Load a document
        processor.LoadDocument("..\\..\\Document.pdf");
    
        // Access the first page's properties
        PdfPageFacade page = processor.DocumentFacade.Pages[0];
    
        // Flatten all rubber stamps
        page.FlattenAnnotations(PdfAnnotationType.RubberStamp);
    }
    

    Remove Rubber Stamp Annotations

    Call the PdfAnnotationFacade.Remove() method to remove an annotation. The following code snippet removes all rubber stamps on the first page.

    using DevExpress.Pdf;
    using System.Linq;
    
    using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
    {
    
      // Load a document
      processor.LoadDocument("..\\..\\Document.pdf");
    
      // Access the first page's properties 
      PdfPageFacade page = processor.DocumentFacade.Pages[0];
    
      // Retrieve all rubber stamps
      var rubberStamps = page.Annotations.Where
        (annotation => annotation.Type == PdfAnnotationType.RubberStamp).ToList();
    
      // Remove all rubber stamps
      foreach (PdfRubberStampAnnotationFacade rubberStamp in rubberStamps)
      {
          rubberStamp.Remove();
      }
    }
    

    Inheritance

    See Also