|
| 1 | +--- |
| 2 | +title: Stamp |
| 3 | +page_title: Stamp Annotation |
| 4 | +description: Stamp annotations display text or graphics intended to look as if they were stamped on the page with a rubber stamp. |
| 5 | +slug: radpdfprocessing-model-annotations-stamp |
| 6 | +tags: annotation, overview, pdfprocessing, stamp |
| 7 | +published: True |
| 8 | +position: 6 |
| 9 | +--- |
| 10 | + |
| 11 | +# Stamp Annotation |
| 12 | + |
| 13 | +A **Stamp annotation** displays text or graphics intended to look as if they were stamped on the page with a rubber stamp. When opened, it displays a pop-up window containing the text of the associated note. |
| 14 | + |
| 15 | +The **StampAnnotation** class is a derivative of the **MarkupAnnotation** (descendent of **ContentAnnotation**) and it exposes the following properties: |
| 16 | + |
| 17 | +|Property|Description| |
| 18 | +|---|---| |
| 19 | +|**Name**|Gets or sets the name of the stamp. The name can be chosen from the predefined names in the __StampAnnotationPredefinedNames__ class or it can be a custom string. In the case of a custom string an appearance should be provided via the __ContentAnnotation.Content__ property.| |
| 20 | +|**Opacity**|Gets or sets the opacity of the annotation.| |
| 21 | +|**Contents**|Gets or sets the text that shall be displayed for the annotation.| |
| 22 | +|**Color**|Gets or sets the color of the annotation.| |
| 23 | +|**Content**|Gets the source defining the visual content of the annotation. This content is with bigger priority compared to the annotation appearance characteristics and text properties and it is visualized by default when opening the exported document in some PDF viewer.| |
| 24 | + |
| 25 | +### Creating a StampAnnotation |
| 26 | + |
| 27 | +```csharp |
| 28 | + RadFixedDocument document = new RadFixedDocument(); |
| 29 | + RadFixedPage page = document.Pages.AddPage(); |
| 30 | + |
| 31 | + RadFixedPage page = fixedDocument.Pages.AddPage(); |
| 32 | + |
| 33 | + StampAnnotation annotation1 = page.Annotations.AddStamp(new Rect(50, 50, 300, 50)); |
| 34 | + annotation1.Name = StampAnnotationPredefinedNames.SBApproved; |
| 35 | + |
| 36 | + StampAnnotation annotation3 = page.Annotations.AddStamp(new Rect(50, 100, 300, 50)); |
| 37 | + annotation3.Name = StampAnnotationPredefinedNames.SBCompleted; |
| 38 | + |
| 39 | + StampAnnotation annotation4 = page.Annotations.AddStamp(new Rect(50, 150, 300, 50)); |
| 40 | + annotation4.Name = StampAnnotationPredefinedNames.SBConfidential; |
| 41 | + |
| 42 | + StampAnnotation annotation5 = page.Annotations.AddStamp(new Rect(50, 200, 300, 50)); |
| 43 | + annotation5.Name = StampAnnotationPredefinedNames.SBDraft; |
| 44 | + |
| 45 | + StampAnnotation annotation6 = page.Annotations.AddStamp(new Rect(50, 250, 300, 50)); |
| 46 | + annotation6.Name = StampAnnotationPredefinedNames.SBFinal; |
| 47 | + |
| 48 | + StampAnnotation annotation7 = page.Annotations.AddStamp(new Rect(50, 300, 300, 50)); |
| 49 | + annotation7.Name = StampAnnotationPredefinedNames.SBForComment; |
| 50 | + |
| 51 | + StampAnnotation annotation8 = page.Annotations.AddStamp(new Rect(50, 350, 300, 50)); |
| 52 | + annotation8.Name = StampAnnotationPredefinedNames.SBForPublicRelease; |
| 53 | + |
| 54 | + StampAnnotation annotation9 = page.Annotations.AddStamp(new Rect(50, 400, 300, 50)); |
| 55 | + annotation9.Name = StampAnnotationPredefinedNames.SBInformationOnly; |
| 56 | + |
| 57 | + StampAnnotation annotation10 = page.Annotations.AddStamp(new Rect(50, 450, 300, 50)); |
| 58 | + annotation10.Name = StampAnnotationPredefinedNames.SBNotApproved; |
| 59 | + |
| 60 | + StampAnnotation annotation11 = page.Annotations.AddStamp(new Rect(50, 500, 300, 50)); |
| 61 | + annotation11.Name = StampAnnotationPredefinedNames.SBNotForPublicRelease; |
| 62 | + |
| 63 | + StampAnnotation annotation13 = page.Annotations.AddStamp(new Rect(50, 550, 300, 50)); |
| 64 | + annotation13.Name = StampAnnotationPredefinedNames.SBPreliminaryResults; |
| 65 | + |
| 66 | + StampAnnotation annotation15 = page.Annotations.AddStamp(new Rect(50, 600, 300, 50)); |
| 67 | + annotation15.Name = StampAnnotationPredefinedNames.SBRejected; |
| 68 | + |
| 69 | + StampAnnotation annotation16 = page.Annotations.AddStamp(new Rect(50, 650, 300, 50)); |
| 70 | + annotation16.Name = StampAnnotationPredefinedNames.SBVoid; |
| 71 | +``` |
| 72 | + |
| 73 | + |
| 74 | + |
| 75 | +### Creating a StampAnnotation with FixedContentEditor |
| 76 | + |
| 77 | +The [FixedContentEditor]({%slug radpdfprocessing-editing-fixedcontenteditor%}) offers the public **DrawStampAnnotation** method which creates a new __StampAnnotation__ and draws it with a specified annotation size and name. |
| 78 | + |
| 79 | +```csharp |
| 80 | + RadFixedDocument fixedDocument = new RadFixedDocument(); |
| 81 | + FixedContentEditor editor = new FixedContentEditor(fixedDocument.Pages.AddPage()); |
| 82 | + |
| 83 | + editor.Position.Translate(100, 100); |
| 84 | + editor.DrawStampAnnotation(new Size(250, 250), StampAnnotationPredefinedNames.SBFinal); |
| 85 | + editor.Position.Translate(400, 100); |
| 86 | + editor.DrawStampAnnotation(new Size(250, 250), StampAnnotationPredefinedNames.SBConfidential); |
| 87 | +``` |
| 88 | + |
| 89 | + |
| 90 | + |
| 91 | +### Creating a StampAnnotation with Appearance |
| 92 | + |
| 93 | +The **AnnotationContentSource** class, accessed by the **Content** property of the annotation object, represents the [FormSource]({%slug radpdfprocessing-model-formsource%}) instances used for displaying the widget content. The following example shows how to create a custom Stamp annotation and change its visual appearance: |
| 94 | + |
| 95 | +>important When creating a custom stamp name (not from the predefined names), it is important to start the name with "#". Otherwise, if the stamp is moved in adobe, its appearance will be rewritten. |
| 96 | +
|
| 97 | +>important When creating appearance for an annotation, it is important to create it with the same size as the rect of the annotation otherwise unexpected behavior may occur when the annotation is moved in Adobe. |
| 98 | +
|
| 99 | +```csharp |
| 100 | + private RadFixedDocument CreateTextAnnotation() |
| 101 | + { |
| 102 | + RadFixedDocument fixedDocument = new RadFixedDocument(); |
| 103 | + RadFixedPage page = fixedDocument.Pages.AddPage(); |
| 104 | + |
| 105 | + StampAnnotation annotation = page.Annotations.AddStamp(new Rect(100, 100, 300, 100)); |
| 106 | + annotation.Name = "#Sold"; |
| 107 | + |
| 108 | + FormSource simpleForm = new FormSource(); |
| 109 | + CreateContentFormWithText(simpleForm, "Sold"); |
| 110 | + |
| 111 | + AnnotationContentSource content = new AnnotationContentSource(); |
| 112 | + annotation.Content.NormalContentSource = simpleForm; |
| 113 | + return fixedDocument; |
| 114 | + } |
| 115 | + |
| 116 | + private static void CreateContentFormWithText(FormSource normalForm, string text) |
| 117 | + { |
| 118 | + normalForm.Size = new Size(300, 100); |
| 119 | + |
| 120 | + FixedContentEditor formEditor = new FixedContentEditor(normalForm); |
| 121 | + |
| 122 | + using (formEditor.SaveProperties()) |
| 123 | + { |
| 124 | + formEditor.GraphicProperties.IsFilled = true; |
| 125 | + formEditor.GraphicProperties.IsStroked = true; |
| 126 | + formEditor.GraphicProperties.StrokeThickness = 2; |
| 127 | + formEditor.GraphicProperties.StrokeColor = new RgbColor(92, 229, 0); |
| 128 | + formEditor.GraphicProperties.FillColor = new RgbColor(213, 222, 226); |
| 129 | + formEditor.GraphicProperties.StrokeDashArray = new double[] { 17, 4 }; |
| 130 | + formEditor.DrawRectangle(new Rect(formEditor.Position.Matrix.OffsetX, formEditor.Position.Matrix.OffsetY, 300,100)); |
| 131 | + } |
| 132 | + |
| 133 | + formEditor.TextProperties.FontSize = 20; |
| 134 | + formEditor.Position.Translate(10, 10); |
| 135 | + formEditor.DrawText(text); |
| 136 | + } |
| 137 | +``` |
| 138 | + |
| 139 | + |
| 140 | + |
| 141 | +## See Also |
| 142 | + |
| 143 | +* [AcroForm]({%slug radpdfprocessing-model-interactive-forms-acroform %}) |
| 144 | +* [FormField]({%slug radpdfprocessing-model-interactive-forms-form-fields%}) |
| 145 | +* [Annotations Overview]({%slug radpdfprocessing-model-annotations-overview%}) |
| 146 | +* [FormSource]({%slug radpdfprocessing-model-formsource%}) |
0 commit comments