> 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/android/annotation/create.md).

# Create annotations

Learn how to add various annotations like sticky notes, links, stamps, and more to PDF documents with full code samples. Enhance your PDFs with text, images, and hyperlinks easily. Master PDF annotati

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 (sticky note) to PDFs

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

{% tabs %}
{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
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 %}
{% endtab %}

{% tab title="Kotlin" %}
{% code lineNumbers="true" %}

```kotlin
val doc = PDFDoc(filename)
val page = doc.getPage(1)

// Create the sticky note (Text annotation)
val txt = Text.create(doc, Rect(10.0, 20.0, 30.0, 40.0))
txt.setIcon("UserIcon")
txt.contents = "The quick brown fox ate the lazy mouse."
txt.setColor(ColorPt(0.0,1.0,0.0))
txt.refreshAppearance()
page.annotPushBack(txt)
```

{% endcode %}
{% endtab %}
{% endtabs %}

[Add or edit PDF annotations](/android/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 PDF link annotation

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

{% tabs %}
{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
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 = com.pdftron.pdf.annots.Link.create(doc.getSDFDoc(), new Rect(85, 458, 503, 502), goto_page_3);
link.refreshAppearance();
page.annotPushBack(link);
```

{% endcode %}
{% endtab %}

{% tab title="Kotlin" %}
{% code lineNumbers="true" %}

```kotlin
val doc = PDFDoc(filename)
val page = doc.getPage(1)

// Create a hyperlink
val hyperlink = Link.create(doc, Rect(85.0, 570.0, 503.0, 524.0), Action.createURI(doc, "http://www.apryse.com"))
hyperlink.refreshAppearance()
page.annotPushBack(hyperlink)

// Create an intra-document link
val goto_page_3 = Action.createGoto(Destination.createFitH(doc.getPage(3), 0.0))
val link = Link.create(doc.sdfDoc, Rect(85.0, 458.0, 503.0, 502.0), goto_page_3)
link.refreshAppearance()
page.annotPushBack(link)
```

{% endcode %}
{% endtab %}
{% endtabs %}

[Add or edit PDF annotations sample](/android/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 a stamp annotation

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.

{% tabs %}
{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
PDFDoc doc = new PDFDoc(filename);
Stamper s = new Stamper(Stamper.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.e_horizontal_right, Stamper.e_vertical_bottom);
s.setAlignment(Stamper.e_horizontal_center, Stamper.e_vertical_top);
s.setFont(Font.create(doc, Font.e_courier, true));
ColorPt red = new ColorPt(1, 0, 0, 0);
s.setFontColor(red); //set color to red
s.setTextAlignment(Stamper.e_align_right);
s.setAsBackground(true); //set text stamp as background
PageSet ps = new PageSet(1, 2);
s.stampText(doc, "This is a title!", ps);

Image img = Image.create(doc, imagename);
s.setAsBackground(false); // set image stamp as foreground
PageSet first_page_ps = new PageSet(1);
s.stampImage(doc, img, first_page_ps);

PDFDoc src_doc = new PDFDoc(src_filename);
Page src_page = src_doc.getPage(1);
s.stampPage(doc, src_page, first_page_ps);
```

{% endcode %}
{% endtab %}

{% tab title="Kotlin" %}
{% code lineNumbers="true" %}

```kotlin
val doc = PDFDoc(filename)
val s = Stamper(Stamper.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.e_horizontal_right, Stamper.e_vertical_bottom)
s.setAlignment(Stamper.e_horizontal_center, Stamper.e_vertical_top)
s.setFont(Font.create(doc, Font.e_courier, true))
val red = ColorPt(1.0, 0.0, 0.0, 0.0)
s.setFontColor(red) //set color to red
s.setTextAlignment(Stamper.e_align_right)
s.setAsBackground(true) //set text stamp as background
val ps = PageSet(1, 2)
s.stampText(doc, "This is a title!", ps)

val img = Image.create(doc, imagename)
s.setAsBackground(false) // set image stamp as foreground
val first_page_ps = PageSet(1)
s.stampImage(doc, img, first_page_ps)

val src_doc = PDFDoc(src_filename)
val src_page = src.getPage(1)
s.stampPage(doc, src_page, ps)
```

{% endcode %}
{% endtab %}
{% endtabs %}

[Stamp a PDF File](/android/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 ](/android/get-started/samples.md#elementbuilder).
{% endtab %}

{% tab title="Highlight" %}

## Add a highlight annotation to a PDF in Android

To add a highlight annotation to a PDF Document page.

{% tabs %}
{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
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 %}
{% endtab %}

{% tab title="Kotlin" %}
{% code lineNumbers="true" %}

```kotlin
val doc = PDFDoc(filename)
val page = doc.getPage(1)

// Create a highlight
val hl = Highlight.create(doc, Rect(100.0, 490.0, 150.0, 515.0))
hl.setColor(ColorPt(0.0, 1.0, 0.0), 3)
hl.refreshAppearance()
page.annotPushBack(hl)
```

{% endcode %}
{% endtab %}
{% endtabs %}

[Add or edit PDF annotations sample](/android/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 a free text annotation to a PDF in Android

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

{% tabs %}
{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
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.e_solid, 1, 10, 20));
txtannot.setEndingStyle(Line.e_ClosedArrow);
txtannot.setColor(new ColorPt(0, 1, 0));
txtannot.setQuaddingFormat(1);
page.annotPushBack(txtannot);
txtannot.refreshAppearance();
```

{% endcode %}
{% endtab %}

{% tab title="Kotlin" %}
{% code lineNumbers="true" %}

```kotlin
val doc = PDFDoc(filename)
val page = doc.getPage(1)

// Create a free text
val txtannot = FreeText.create(doc, Rect(100.0, 100.0, 350.0, 500.0))
txtannot.contentRect = Rect(200.0, 200.0, 350.0, 500.0)
txtannot.contents = "\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(Point(200.0, 300.0), Point(150.0, 290.0), Point(110.0, 110.0))
txtannot.borderStyle = BorderStyle(BorderStyle.e_solid, 1, 10, 20)
txtannot.endingStyle = Line.e_ClosedArrow
txtannot.setColor(ColorPt(0.0, 1.0, 0.0))
txtannot.quaddingFormat = 1
page.annotPushBack(txtannot)
txtannot.refreshAppearance()
```

{% endcode %}
{% endtab %}
{% endtabs %}

[Add or edit PDF annotations sample](/android/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 a rectangle annotation to a PDF in Android

To add a rectangle annotation to a PDF Document page.

{% tabs %}
{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
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 = {4, 2};
sq.setBorderStyle(new Annot.BorderStyle(Annot.BorderStyle.e_dashed, 6, 0, 0, dash));
sq.setPadding(4);
sq.refreshAppearance();
page.annotPushBack(sq);
```

{% endcode %}
{% endtab %}

{% tab title="Kotlin" %}
{% code lineNumbers="true" %}

```kotlin
val doc = PDFDoc(filename)
val page = doc.getPage(1)

// Create a rectangle
val sq = Square.create(doc, Rect(500.0, 200.0, 580.0, 300.0))
sq.setColor(ColorPt(1.0, 0.0, 0.0), 3)
sq.setInteriorColor(ColorPt(0.0, 1.0, 1.0), 3)
val dash = doubleArrayOf(4.0, 2.0)
sq.borderStyle = BorderStyle(BorderStyle.e_dashed, 6, 0, 0, dash)
sq.setPadding(4.0)
sq.refreshAppearance()
page.annotPushBack(sq)
```

{% endcode %}
{% endtab %}
{% endtabs %}

[Add or edit PDF annotations sample](/android/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/android/annotation/create.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.
