Document Solutions for PDF
Features / Stamps
In This Topic
    Stamps
    In This Topic

    Stamps are generally used to personalize, apply branding, and indicate status of the documents, which can be easily moved and modified. A stamp annotation is intended to look as if it is stamped on the page with a rubber stamp just like conventional paper documents. On clicking, it displays a pop-up window containing the text of the associated note. For more information on stamp annotation, refer PDF specification 1.7 (Section 12.5.6.12).

    DsPdf allows you to add stamps to a PDF document, using StampAnnotation class. These stamps are text stamp and image stamp. Text stamp allows you to add page numbers, text, and dynamic text stamps like Date, Time, Author to the document. On the other hand, image stamps allow you to add images as stamps and create stamps from PDF, JPG, JPG2000, BMP, and PNG files. The library also lets you to specify possible icons, such as "Confidential", "Departmental", etc., to display the stamps using Icon property of StampAnnotation class, which takes the value from StampAnnotationIcon enum.

    PDF Stamps

    Add Stamp

    To add a stamp in a PDF document, use the StampAnnotation class. The StampAnnotation class provides the essential properties for creating an image or text stamp that looks similar to a rubber stamp.

    To add a stamp:

    1. Create an object of GcPdfDocument and StampAnnotation class.
    2. Set the required properties of StampAnnotation object.
    3. Call the Add method to add the stamp on the page.
      C#
      Copy Code
      public void CreatePDF(Stream stream)
      {
          GcPdfDocument doc = new GcPdfDocument();
          var page = doc.NewPage();
      
          //Add Stamp
          var stamp = new StampAnnotation()
          {
              Contents = "This is a sample stamp",
              Color = Color.Aqua,
              Icon = StampAnnotationIcon.Confidential.ToString(),
              CreationDate = DateTime.Today,
              Rect = new RectangleF(100.5F, 110.5F, 72, 72),
          };
      
          // Add stamp to page
          page.Annotations.Add(stamp);
          //Save Document
          doc.Save(stream);
      }
      
    Back to Top

    Modify Stamp

    To modify stamp annotation, you can set the properties of stamp annotation you used on a page. For instance, setting Contents property of AnnotationBase class and Color property of the StampAnnotation class modifies the existing content and color of the annotation.

    C#
    Copy Code
    stamp.Contents = "Draft Copy";
    stamp.Color = Color.Red;
    
    Back to Top

    Delete Stamp

    To delete a particular stamp annotation in PDF document, use RemoveAt method to remove the stamp by specifying its index value. Apart from this, Clear method can be used to remove all the stamp annotations from the document.

    C#
    Copy Code
    // Delete a particular stamp annotation
    page.Annotations.RemoveAt(0);
    
    // Delete all stamp annotations
    page.Annotations.Clear();
    
    Back to Top

    For more information about implementation of stamps using DsPdf, see DsPdf sample browser.