Add a free text annotation to a PDF on Server/Desktop

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

1$doc = new PDFDoc($filename);
2$page = $doc->GetPage(1);
3
4// Create a free text
5$txtannot = FreeText::Create( $doc->GetSDFDoc(), new Rect(100.0, 100.0, 350.0, 500.0) );
6$txtannot->SetContentRect( new Rect( 200.0, 200.0, 350.0, 500.0 ) );
7$txtannot->SetContents("\n\nSome swift brown fox snatched a gray hare out of the air by freezing it with an angry glare."
8 ."\n\nAha!\n\nAnd there was much rejoicing!");
9$txtannot->SetCalloutLinePoints( new Point(200.0,300.0), new Point(150.0,290.0), new Point(110.0,110.0) );
10$txtannot->SetBorderStyle( new BorderStyle( BorderStyle::e_solid, 1.0, 10.0, 20.0 ), true );
11$txtannot->SetEndingStyle( LineAnnot::e_ClosedArrow );
12$txtannot->SetColor( new ColorPt( 0.0, 1.0, 0.0 ) );
13$txtannot->SetQuaddingFormat(1);
14$page->AnnotPushBack($txtannot);
15$txtannot->RefreshAppearance();

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).

Did you find this helpful?

Trial setup questions?

Ask experts on Discord

Need other help?

Contact Support

Pricing or product questions?

Contact Sales