use strict; use warnings; use PDF::API2; use PDF::API2::Basic::PDF::Utils; my $pdf = PDF::API2-> new; my $page = $pdf-> page; my $font = $pdf-> corefont( 'Helvetica-Bold' ); my $text = $page-> text; $text-> font( $font, 20 ); $text-> translate( 100, 700 ); $text-> text( 'Hello World!' ); my $sticky = $page-> annotation; $sticky-> text( 'Text in pop-up window', -rect => [ 100, 500, 100, 500 ], -open => 1 ); # not really a bbox, # just couple of coords $sticky-> { C } = PDFArray( map PDFNum( $_ ), 1, 0.65, 0 ); # orange, make user happy my $free = $page-> annotation; $free-> { Subtype } = PDFName( 'FreeText' ); $free-> { DA } = PDFStr( '0 0 0 rg /Helv 12 Tf' ); # set text size here $free-> content( 'This is a free text annotation' ); $free-> border( 0, 0, 0 ); # no border $free-> rect( 100, 600, 300, 620 ); # real bbox this time $free-> { C } = PDFArray( map PDFNum( $_ ), 0.9, 1, 1 ); # faint blue background $pdf->saveas( 'out.pdf' );