Some test text!

Hamburger Icon

Php / Guides / Add free text annotation

Add a free text annotation to a PDF in PHP

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

$doc = new PDFDoc($filename);
$page = $doc->GetPage(1);

// Create a free text
$txtannot = FreeText::Create( $doc->GetSDFDoc(), new Rect(100.0, 100.0, 350.0, 500.0)  );
$txtannot->SetContentRect( new Rect( 200.0, 200.0, 350.0, 500.0 ) );
$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.0,300.0), new Point(150.0,290.0), new Point(110.0,110.0) );
$txtannot->SetBorderStyle( new BorderStyle( BorderStyle::e_solid, 1.0, 10.0, 20.0 ), true );
$txtannot->SetEndingStyle( LineAnnot::e_ClosedArrow );
$txtannot->SetColor( new ColorPt( 0.0, 1.0, 0.0 ) );

Add or edit PDF annotations sample
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).

Get the answers you need: Chat with us