All docs
V21.2
21.2
21.1
The page you are viewing does not exist in version 21.1. This link will take you to the root page.
20.2
The page you are viewing does not exist in version 20.2. This link will take you to the root page.
20.1
The page you are viewing does not exist in version 20.1. This link will take you to the root page.
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+

PdfRubberStampAnnotationFacade Class

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

Namespace: DevExpress.Pdf

Assembly: DevExpress.Pdf.v21.2.Core.dll

Declaration

public class PdfRubberStampAnnotationFacade :
    PdfMarkupAnnotationFacade

Remarks

Create Rubber Stamp Annotations

The code sample below 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 code sample below creates a Reviewed dynamic 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 "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 code sample below 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 properties
    PdfDocumentFacade facade = processor.DocumentFacade;
    PdfPageFacade page = processor.DocumentFacade.Pages[0];

    // Define 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, "demo stamp", customStampFile, 2);
    rubberStamp.Author = "Jesse Faden";
}

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 code sample below 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 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 code sample below 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 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 code sample below 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 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