PDF::API2::Annotation(3pm) | User Contributed Perl Documentation | PDF::API2::Annotation(3pm) |
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.
$annotation = $annotation->pdf($file, $page_number, $location, @args);
Open the PDF file located at $file to the specified page number. $location and @args are optional and set which part of the page should be displayed, as defined in "destination" in PDF::API2::NamedDestination.
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.
2024-05-22 | perl v5.38.2 |