WatermarkAnnotation class
WatermarkAnnotation class
Represents watermark annotation properties.
- More about annotation types and annotating PDF and Microsoft Word documents, Excel spreadsheets and PowerPoint Presentations: https://docs.groupdocs.com/display/annotationnet/Add+annotation+to+the+document
- More about adding watermark annotations to documents of various types: https://docs.groupdocs.com/display/annotationnet/Add+watermark+annotation
The WatermarkAnnotation type exposes the following members:
Constructors
| Constructor | Description |
|---|---|
| init | Initializes new instance of WatermarkAnnotation class. |
Methods
| Method | Description |
|---|---|
| clone | Returns a new instance with the same values. |
| equals | Compares watermark annotation using IEquatable Equals method. |
| equals | Compares watermark annotation using the standard object Equals method. |
| equals_object | |
| equals_watermark_annotation | |
| get_hash_code | Returns the hash code of the watermark annotation. |
| equals_annotation_base | (inherited from AnnotationBase) |
Properties
| Property | Description |
|---|---|
| angle | The rotation angle of the watermark annotation. |
| auto_scale | The auto scale setting for the watermark annotation. |
| box | The watermark annotation position. |
| font_color | The watermark annotation text color. |
| font_family | The font family of the watermark annotation text. |
| font_size | The watermark annotation text size. |
| horizontal_alignment | The watermark horizontal alignment on the document. |
| opacity | The opacity of the watermark annotation. |
| text | The watermark text. |
| vertical_alignment | The vertical alignment of the watermark on the document. |
| created_on | The annotation creation date. (inherited from AnnotationBase) |
| id | The annotation unique identifier. This field is auto-incremented. (inherited from AnnotationBase) |
| message | The annotation message. (inherited from AnnotationBase) |
| page_number | The page number where the annotation should be located. (inherited from AnnotationBase) |
| replies | The list of replies (comments) attached to the annotation. (inherited from AnnotationBase) |
| state_before_annotation | The previous state of the text before annotating. (inherited from AnnotationBase) |
| type | The annotation type. (inherited from AnnotationBase) |
| user | The annotation author. (inherited from AnnotationBase) |
Example
from groupdocs.annotation import Annotator
from groupdocs.annotation.models import Rectangle, HorizontalAlignment, VerticalAlignment
from groupdocs.annotation.models.annotation_models import WatermarkAnnotation
from groupdocs.pydrawing import Color
def add_watermark_annotation():
with Annotator("./sample.pdf") as annotator:
watermark = WatermarkAnnotation()
watermark.box = Rectangle(100, 100, 200, 100)
watermark.text = "Watermark"
watermark.font_family = "Arial"
watermark.font_size = 24.0
watermark.font_color = Color.red.to_argb()
watermark.angle = 45.0
watermark.auto_scale = True
watermark.horizontal_alignment = HorizontalAlignment.CENTER
watermark.vertical_alignment = VerticalAlignment.CENTER
watermark.opacity = 0.5
watermark.page_number = 0
watermark.message = "This is a watermark annotation"
annotator.add(watermark)
annotator.save("./output.pdf")
Guides
Task guides that use WatermarkAnnotation: