> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/xamarin/annotation/create-annotations.md).

# Create annotations

Learn how to add various annotations to PDF documents using Xamarin viewer, including sticky notes, links, stamps, and more. Full code samples provided for adding or editing PDF annotations. Stamp tex

A variety of annotations can be created such as sticky note (text annotations), link annotations, stamp annotations, and more.

{% tabs %}
{% tab title="Text" %}

## Add text annotation to a document with Xamarin viewer

To add a sticky note (text annotation) to a PDF Document.

{% code lineNumbers="true" %}

```csharp
PDFDoc doc = new PDFDoc(filename);
Page page = doc.GetPage(1);

// Create the sticky note (Text annotation)
Text txt = Text.Create(doc, new Rect( 10, 20, 30, 40 ));
txt.SetIcon("UserIcon");
txt.SetContents("The quick brown fox ate the lazy mouse.");
txt.SetColor(new ColorPt(0,1,0));
txt.RefreshAppearance();
page.AnnotPushBack(txt);
```

{% endcode %}

[Add or edit PDF annotations](/xamarin/get-started/samples.md#annotation) Full code sample which shows how to add or edit PDF annotations (e.g. hyperlink, intra-document link, stamp, rubber stamp, file attachment, sound, text, free-text, line, circle, square, polygon, polyline, highlight, squiggly, caret, and ink).
{% endtab %}

{% tab title="Link" %}

## Add link annotation to a document with Xamarin viewer

To add a hyperlink or intra-document link annotation to a PDF Document page.

{% code lineNumbers="true" %}

```csharp
PDFDoc doc = new PDFDoc(filename);
Page page = doc.GetPage(1);

// Create a hyperlink
Link hyperlink = Link.Create(doc, new Rect(85, 570, 503, 524), Action.CreateURI(doc, "http://www.apryse.com"));
hyperlink.RefreshAppearance();
page.AnnotPushBack(hyperlink);

// Create an intra-document link
Action goto_page_3 = Action.CreateGoto(Destination.CreateFitH(doc.GetPage(3), 0));
Link link = Link.Create(doc, new Rect(85, 458, 503, 502), goto_page_3);
link.RefreshAppearance();
page.AnnotPushBack(link);
```

{% endcode %}

[Add or edit PDF annotations sample](/xamarin/get-started/samples.md#annotation) Full code sample which shows how to add or edit PDF annotations (e.g. hyperlink, intra-document link, stamp, rubber stamp, file attachment, sound, text, free-text, line, circle, square, polygon, polyline, highlight, squiggly, caret, and ink).
{% endtab %}

{% tab title="Stamp" %}

## Add stamp annotation to a PDF in Xamarin

A stamp in a PDF document is analogous to applying a rubber stamp on a paper document.

Apryse SDK benefits include:

* Stamp PDF pages with text, images, or with other PDF pages.
* Embed fonts and images, and copy graphical elements from one page to another.

## Use Stamper to stamp content (text, image, PDF page)

To stamp text, image, and a PDF page to a PDF document.

{% code lineNumbers="true" %}

```csharp
PDFDoc doc = new PDFDoc(filename);
Stamper s = new Stamper(Stamper.SizeType.e_relative_scale, .05, .05)

// Specifies if the stamp is to be stamped as an annotation.
// note that stamps created with this setting do not work with SetAsBackground, HasStamps, and DeleteStamps, if annotation is true.
//s.SetAsAnnotation(true);

s.SetAlignment(Stamper.HorizontalAlignment.e_horizontal_right, Stamper.VerticalAlignment.e_vertical_bottom);
s.SetAlignment(Stamper.HorizontalAlignment.e_horizontal_center, Stamper.VerticalAlignment.e_vertical_top);
s.SetFont(Font.Create(doc, Font.StandardType1Font.e_courier, true));
s.SetFontColor(new ColorPt(1, 0, 0, 0)); //set color to red
s.SetTextAlignment(Stamper.TextAlignment.e_align_right);
s.SetAsBackground(true); //set text stamp as background
s.StampText(doc, "This is a title!", new PageSet(1, 2));

Image img = Image.Create(doc, imagename);
s.SetAsBackground(false); // set image stamp as foreground
s.StampImage(doc, img, new PageSet(1));

PDFDoc src_doc = new PDFDoc(src_filename);
Page src_page = src_doc.GetPage(1);
s.StampPage(doc, src_page, new PageSet(1));
```

{% endcode %}

[Stamp a PDF File](/xamarin/get-started/samples.md#stamper) Full code sample which shows how to stamp PDF pages with text, images, or with other PDF pages and how to add new content (or watermark).

## About Stamper

Stamper can be used for PDF pages with text, images, or with other PDF content in only a few lines of code. Although Stamper is very simple to use compared to ElementBuilder/ElementWriter it is not as powerful or flexible. In case you need full control over PDF creation use ElementBuilder/ElementWriter to add new content to existing PDF pages as shown in the [ElementBuilder sample project](/xamarin/get-started/samples.md#elementbuilder).
{% endtab %}

{% tab title="Highlight" %}

## Add hihglight annotation to a PDF in Xamarin

To add a highlight annotation to a PDF Document page.

{% code lineNumbers="true" %}

```csharp
PDFDoc doc = new PDFDoc(filename);
Page page = doc.GetPage(1);

// Create a highlight
Highlight hl = Highlight.Create( doc, new Rect(100,490,150,515) );
hl.SetColor(new ColorPt(0,1,0), 3 );
hl.RefreshAppearance();
page.AnnotPushBack(hl);
```

{% endcode %}

[Add or edit PDF annotations sample](/xamarin/get-started/samples.md#annotation) Full code sample which shows how to add or edit PDF annotations (e.g. hyperlink, intra-document link, stamp, rubber stamp, file attachment, sound, text, free-text, line, circle, square, polygon, polyline, highlight, squiggly, caret, and ink).
{% endtab %}

{% tab title="Free text" %}

## Add free text annotation to a PDF in Xamarin

To add a free text annotation to a PDF Document page.

{% code lineNumbers="true" %}

```csharp
PDFDoc doc = new PDFDoc(filename);
Page page = doc.GetPage(1);

// Create a free text
FreeText txtannot = FreeText.Create( doc, new Rect(100, 100, 350, 500)  );
txtannot.SetContentRect( new Rect( 200, 200, 350, 500 ) );
txtannot.SetContents( "\n\nSome swift brown fox snatched a gray hare out of the air by freezing it with an angry glare." +
                        "\n\nAha!\n\nAnd there was much rejoicing!" );
txtannot.SetCalloutLinePoints( new Point(200,300), new Point(150,290), new Point(110,110) );
txtannot.SetBorderStyle(new Annot.BorderStyle(Annot.BorderStyle.Style.e_solid, 1, 10, 20 ) );
txtannot.SetEndingStyle(Line.EndingStyle.e_ClosedArrow );
txtannot.SetColor( new ColorPt( 0, 1, 0 ) );
txtannot.SetQuaddingFormat(1);
page.AnnotPushBack(txtannot);
txtannot.RefreshAppearance();
```

{% endcode %}

[Add or edit PDF annotations sample](/xamarin/get-started/samples.md#annotation) Full code sample which shows how to add or edit PDF annotations (e.g. hyperlink, intra-document link, stamp, rubber stamp, file attachment, sound, text, free-text, line, circle, square, polygon, polyline, free text, squiggly, caret, and ink).
{% endtab %}

{% tab title="Rectangle" %}

## Add rectangle annotation to a PDF in Xamarin

To add a rectangle annotation to a PDF Document page.

{% code lineNumbers="true" %}

```csharp
PDFDoc doc = new PDFDoc(filename);
Page page = doc.GetPage(1);

// Create a rectangle
Square sq = Square.Create( doc, new Rect(500,200, 580, 300 ) );
sq.SetColor(new ColorPt(1, 0, 0), 3);
sq.SetInteriorColor(new ColorPt(0, 1, 1), 3);
double[] dash = new double[2];
dash[0]=4;dash[1]=2;
sq.SetBorderStyle(new Annot.BorderStyle( Annot.BorderStyle.Style.e_dashed, 6, 0, 0, dash ) );
sq.SetPadding( new Rect(4,4,4,4) );
sq.RefreshAppearance();
page.AnnotPushBack( sq );
```

{% endcode %}

[Add or edit PDF annotations sample](/xamarin/get-started/samples.md#annotation) Full code sample which shows how to add or edit PDF annotations (e.g. hyperlink, intra-document link, stamp, rubber stamp, file attachment, sound, text, free-text, line, circle, square, polygon, polyline, rectangle, squiggly, caret, and ink).
{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/xamarin/annotation/create-annotations.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
