Some test text!

Search
Hamburger Icon

Go / Guides / Add free text annotation

Add a free text annotation to a PDF in Go

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

doc := NewPDFDoc(filename)
page := doc.GetPage(1)

// Create a free text
txtannot := FreeTextCreate( doc.GetSDFDoc(), NewRect(100.0, 100.0, 350.0, 500.0)  )
txtannot.SetContentRect( NewRect(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( NewPoint(200.0,300.0), NewPoint(150.0,290.0), NewPoint(110.0,110.0) )
txtannot.SetBorderStyle( NewBorderStyle( BorderStyleE_solid, 1.0, 10.0, 20.0 ), false )
txtannot.SetEndingStyle( LineAnnotE_ClosedArrow )
txtannot.SetColor( NewColorPt( 0.0, 1.0, 0.0 ) )
txtannot.SetQuaddingFormat(1)
page.AnnotPushBack(txtannot)
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).

Get the answers you need: Chat with us