---
name: "PDF::API2::Annotation"
section: "3pm"
platform: "linux"
package: "perl-pdf-api2"
version: "2.048-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/PDF::API2::Annotation"
---

# PDF::API2::Annotation(3pm)

Add annotations to a PDF

## NAME

PDF::API2::Annotation - Add annotations to a PDF

## SYNOPSIS

```
    my $pdf = PDF::API2->new();
    my $font = $pdf->font('Helvetica');
    my $page1 = $pdf->page();
    my $page2 = $pdf->page();
    my $content = $page1->text();
    my $message = 'Go to Page 2';
    my $size = 18;
    $content->distance(1 * 72, 9 * 72);
    $content->font($font, $size);
    $content->text($message);
    my $annotation = $page1->annotation();
    my $width = $content->text_width($message);
    $annotation->rect(1 * 72, 9 * 72, 1 * 72 + $width, 9 * 72 + $size);
    $annotation->link($page2);
    $pdf->save('sample.pdf');
```

## METHODS

### Annotation Types

*link*

```
    $annotation = $annotation->link($destination, $location, @args);
```

Link the annotation to another page in this PDF.  `$location` and `@args` are optional and set which part of the page should be displayed, as defined in "destination" in PDF::API2::NamedDestination.

`$destination` can be either a PDF::API2::Page object or the name of a named destination defined elsewhere.

*url*

```
    $annotation = $annotation->uri($uri);
```

Launch `$uri` -- typically a web page -- when the annotation is selected.

*file*

```
    $annotation = $annotation->launch($file);
```

Open `$file` when the annotation is selected.

*pdf*

```
    $annotation = $annotation->pdf($file, $dest, $location, @args);
```

Open the PDF file located at `$file` to the specified destination. `$location` and `@args` are optional and set which part of the page should be displayed, as defined in "destination" in PDF::API2::NamedDestination.

`$dest` can be a page number, or a named destination prefixed with `"#"`.

*text*

```
    $annotation = $annotation->text($text);
```

Define the annotation as a text note with the specified content.

*movie*

```
    $annotation = $annotation->movie($filename, $content_type);
```

Embed and link to the movie located at `$filename` with the specified MIME type.

### Common Annotation Attributes

*rect*

```
    $annotation = $annotation->rect($llx, $lly, $urx, $ury);
```

Define the rectangle around the annotation.

*border*

```
    $annotation = $annotation->border($h_radius, $v_radius, $width);
```

Define the border style.  Defaults to 0, 0, 0 (no border).

*content*

```
    $annotation = $annotation->content(@lines);
```

Define the text content of the annotation, if applicable.

*open*

```
    $annotation = $annotation->open($boolean);
```

Set the annotation to initially be either open or closed.  Only relevant for text annotations.
