Skip to content

Commit 2b4fd99

Browse files
committed
TextMarkup annotations
1 parent 1c8011d commit 2b4fd99

12 files changed

+181
-3
lines changed
59 KB
Loading
248 KB
Loading
1.65 KB
Loading
1.3 KB
Loading
18.4 KB
Loading
1.18 KB
Loading

libraries/radpdfprocessing/model/annotations/links.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: Links
33
page_title: Links
4+
description: Link annotations represent either a hypertext link to a destination elsewhere in the document or an action to be performed.
45
slug: radpdfprocessing-model-annotations-links
56
tags: annotations,overview,pdfprocessing,link,links
67
published: True

libraries/radpdfprocessing/model/annotations/overview.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: Annotations Overview
33
page_title: Annotations Overview
4+
description: Learn what annotation types are supported in the PdfProcessing library offered by the Telerik Document Processing.
45
slug: radpdfprocessing-model-annotations-overview
56
tags: annotations,overview,pdfprocessing
67
published: True
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
---
2+
title: Text Markup
3+
page_title: Text Markup Annotation
4+
description: Text markup annotations appear as highlights, underlines, strikeouts, or squiggly underlines in the text of a document.
5+
slug: radpdfprocessing-model-annotations-text-markup
6+
tags: annotation, overview, pdfprocessing, text, markup
7+
published: True
8+
position: 4
9+
---
10+
11+
# TextMarkup
12+
13+
**Text Markup annotations** appear as highlights, underlines, strikeouts, or jagged ("squiggly") underlines in the text of a document. When opened, they display a pop-up window containing the text of the associated note.
14+
15+
![Text Markup Annotation](images/pdf-processing-create-text-markup-annotation.png)
16+
17+
The **TextMarkupAnnotation** class is a derivative of the **MarkupAnnotation** (descendent of **ContentAnnotation**) and it exposes the following properties:
18+
19+
|Property|Description|
20+
|---|---|
21+
|**TextMarkupType**|Gets the type of the annotation. The **TextMarkupAnnotationType** enum offers *Highlight*, *StrikeOut*, *Underline*, *Squiggly* options.|
22+
|**Opacity**|Gets or sets the opacity of the annotation.|
23+
|**Contents**|Gets or sets the text that shall be displayed for the annotation.|
24+
|**Color**|Gets or sets the color of the annotation.|
25+
|**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.|
26+
27+
Depending on the TextMarkupAnnotationType the respective type of the TextMarkup annotation can be added to the PDF document using the below examples:
28+
29+
## Highlight
30+
31+
### Creating a Highlight Annotation
32+
33+
```csharp
34+
string sampleText = File.ReadAllText("dummyText.txt");
35+
36+
RadFixedDocument fixedDocument = new RadFixedDocument();
37+
using (RadFixedDocumentEditor documentEditor = new RadFixedDocumentEditor(fixedDocument))
38+
{
39+
documentEditor.InsertRun(sampleText);
40+
}
41+
TextSearch search = new TextSearch(fixedDocument);
42+
IEnumerable<SearchResult> result = search.FindAll("amet", TextSearchOptions.Default);
43+
foreach (SearchResult r in result)
44+
{
45+
Rect highlightRectangle = r.GetWordBoundingRect();
46+
TextMarkupAnnotation annotation = r.GetResultPage().Annotations.AddHighlight(highlightRectangle);
47+
annotation.Color = new RgbColor(125, 255, 0, 0);
48+
49+
annotation.RecalculateContent();
50+
}
51+
52+
```
53+
54+
![Create Highlight Annotation](images/pdf-processing-create-highlight-annotation.png)
55+
56+
### Creating a Highlight Annotation with Appearance
57+
58+
59+
```csharp
60+
private RadFixedDocument CreateTextMarkupAnnotation()
61+
{
62+
string sampleText = File.ReadAllText("dummyText.txt");
63+
RadFixedDocument fixedDocument = new RadFixedDocument();
64+
using (RadFixedDocumentEditor documentEditor = new RadFixedDocumentEditor(fixedDocument))
65+
{
66+
documentEditor.InsertRun(sampleText);
67+
}
68+
TextMarkupAnnotation annotation = fixedDocument.Pages[0].Annotations.AddHighlight(new Rect(150, 150, 100, 40));
69+
70+
FormSource simpleForm = new FormSource();
71+
CreateContentFormWithText(simpleForm, "Hover me!");
72+
annotation.Content.NormalContentSource = simpleForm;
73+
74+
FormSource secondForm = new FormSource();
75+
CreateContentFormWithText(secondForm, "Hovered!");
76+
annotation.Content.MouseOverContentSource = secondForm;
77+
return fixedDocument;
78+
}
79+
80+
private static void CreateContentFormWithText(FormSource normalForm, string text)
81+
{
82+
Size s = new Size(100, 40);
83+
Random rand= new Random();
84+
normalForm.Size = s;
85+
86+
FixedContentEditor formEditor = new FixedContentEditor(normalForm);
87+
88+
using (formEditor.SaveProperties())
89+
{
90+
formEditor.GraphicProperties.IsFilled = true;
91+
formEditor.GraphicProperties.IsStroked = true;
92+
formEditor.GraphicProperties.StrokeThickness = 1;
93+
formEditor.GraphicProperties.StrokeColor = new RgbColor(255, 0, 0);
94+
formEditor.GraphicProperties.FillColor = new RgbColor(175,255, 255, 0);
95+
formEditor.GraphicProperties.StrokeDashArray = new double[] { 17, 4 };
96+
formEditor.DrawRectangle(new Rect(s));
97+
}
98+
99+
formEditor.TextProperties.FontSize = 16;
100+
formEditor.Position.Translate(10, 10);
101+
formEditor.DrawText(text);
102+
}
103+
```
104+
105+
![Create Highlight Annotation with Appearance](images/pdf-processing-create-highlight-annotation-with-appearance.gif)
106+
107+
## Underline
108+
109+
```csharp
110+
RadFixedDocument fixedDocument = new RadFixedDocument();
111+
RadFixedPage page = fixedDocument.Pages.AddPage();
112+
FixedContentEditor editor = new FixedContentEditor(page);
113+
editor.Position.Translate(100, 100);
114+
editor.DrawText("This is an underline.");
115+
116+
TextSearch search = new TextSearch(fixedDocument);
117+
IEnumerable<SearchResult> underlineSearch = search.FindAll("underline", TextSearchOptions.Default);
118+
Rect underlineRectangle = underlineSearch.First().GetWordBoundingRect();
119+
TextMarkupAnnotation underlineAnnotation = page.Annotations.AddUnderline(underlineRectangle);
120+
underlineAnnotation.Color = new RgbColor(255, 0, 255);
121+
underlineAnnotation.Opacity = 0.90;
122+
underlineAnnotation.RecalculateContent();
123+
```
124+
125+
![Create Underline Annotation](images/pdf-processing-create-underline-annotation.png)
126+
127+
## Squiggly
128+
129+
```csharp
130+
RadFixedDocument fixedDocument = new RadFixedDocument();
131+
RadFixedPage page = fixedDocument.Pages.AddPage();
132+
FixedContentEditor editor = new FixedContentEditor(page);
133+
editor.Position.Translate(100, 100);
134+
editor.DrawText("This is a squiggly line.");
135+
136+
TextSearch search = new TextSearch(fixedDocument);
137+
IEnumerable<SearchResult> squigglySearch = search.FindAll("squiggly", TextSearchOptions.Default);
138+
Rect squigglyRectangle = squigglySearch.First().GetWordBoundingRect();
139+
TextMarkupAnnotation squigglyAnnotation = page.Annotations.AddSquiggly(squigglyRectangle);
140+
squigglyAnnotation.Color = new RgbColor (255,0, 0);
141+
squigglyAnnotation.Opacity = 0.70;
142+
squigglyAnnotation.RecalculateContent();
143+
```
144+
145+
![Create Squiggly Annotation](images/pdf-processing-create-squiggly-annotation.png)
146+
147+
## StrikeOut
148+
149+
```csharp
150+
RadFixedDocument fixedDocument = new RadFixedDocument();
151+
RadFixedPage page = fixedDocument.Pages.AddPage();
152+
FixedContentEditor editor = new FixedContentEditor(page);
153+
editor.Position.Translate(100, 100);
154+
editor.DrawText("This is an underline.");
155+
156+
TextSearch search = new TextSearch(fixedDocument);
157+
IEnumerable<SearchResult> underlineSearch = search.FindAll("underline", TextSearchOptions.Default);
158+
Rect underlineRectangle = underlineSearch.First().GetWordBoundingRect();
159+
TextMarkupAnnotation underlineAnnotation = page.Annotations.AddUnderline(underlineRectangle);
160+
underlineAnnotation.Color = new RgbColor(255, 0, 255);
161+
underlineAnnotation.Opacity = 0.90;
162+
underlineAnnotation.RecalculateContent();
163+
```
164+
165+
![Create StrikeOut Annotation](images/pdf-processing-create-strikeOut-annotation.png)
166+
167+
168+
169+
## See Also
170+
171+
* [AcroForm]({%slug radpdfprocessing-model-interactive-forms-acroform %})
172+
* [FormField]({%slug radpdfprocessing-model-interactive-forms-form-fields%})
173+
* [Annotations Overview]({%slug radpdfprocessing-model-annotations-overview%})
174+
* [FormSource]({%slug radpdfprocessing-model-formsource%})

libraries/radpdfprocessing/model/annotations/text.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
---
22
title: Text
33
page_title: Text Annotation
4+
description: Text annotations represents a sticky note attached to a point in the PDF document.
45
slug: radpdfprocessing-model-annotations-text
5-
tags: annotations, overview, pdfprocessing, text
6+
tags: annotation, overview, pdfprocessing, text
67
published: True
78
position: 3
89
---

0 commit comments

Comments
 (0)