A stamp annotation displays graphics, images, or texts to look as if they were stamped on a page. Upon opening, the stamp annotations display a pop-up window with the text of the associated note. DsPdf provides StampAnnotation class to enable users to apply stamp annotations to the PDF file.
StampAnnotation class provides the following members to set various options for the stamp annotation:
Member | Description |
---|---|
UserName | Adds the user name to the text label in the title bar of the annotation’s pop-up window when the annotation is open and active. |
Subject | Adds the text representing the subject of the annotation. |
Contents | Adds the text to the annotation for display. |
RichText | Adds the text to the annotation for display in the pop-up window when opened. You can format this text using HTML tags. |
Opacity | Sets the opacity of the annotation. |
Icon | Sets a string specifying the name of an icon used to display the annotation. The PDF specification provides a predefined set of icons; those are provided by the StampAnnotationIcon enumeration. |
RotateContent | Rotates the annotation content by the specified angle. Positive values indicate a counterclockwise rotation. |
BorderWidth | Sets the border width. |
Color | Sets the annotation color, popup window color, line color, etc. |
Font | Sets a font to draw the stamp. |
PdfRect | Sets the rectangle that defines the location and size of the annotation on a page in PDF user space coordinates. The positive X axis extends horizontally to the right, and the positive Y axis extends vertically upward, with the origin usually in the lower left corner of the page. |
Refer to the following example code to add a stamp annotation to a PDF document:
C# |
Copy Code
|
---|---|
public void CreateStampAnnotation() { GcPdfDocument doc = new GcPdfDocument(); var page = doc.NewPage(); //Create an instance of StampAnnotation class and set its relevant properties var stamp = new StampAnnotation() { Contents = "This is a sample stamp", UserName = "Jamie Smith", Color = Color.SkyBlue, Icon = StampAnnotationIcon.Confidential.ToString(), CreationDate = DateTime.Today, PdfRect = new RectangleF(100.5F, 110.5F, 72, 72), }; page.Annotations.Add(stamp); //Add the stamp annotation doc.Save("StampAnnotation.pdf"); } |