A quick and dirty approach to add a text box to an existing page.

Q: I need to add a text box to an existing PDF page (i.e. to stamp a
page with a paragraph). I looked at ElementBuilder sample project and
I see how to write the text using explicit layout information. This is
nice, however I would prefer a simpler (and possibly less flexible
approach) way to fill a given region with text.
-----------------------
A: A quick and dirty way to place a multi-line text within a given
rectangle would be to create a new text widget annotation, set multi-
line flag to true, call field.RefreshAppearance(), followed by
field.FlattenField(). For a concrete example of how to create a text
field please take a look at InteractiveForms sample project (http://
www.pdftron.com/net/samplecode.html#InteractiveForms). So the
pseudocode may look as follows:

// In C++
Field fld= pdfdoc.FieldCreate("Text000", Field::e_text, "My text 1. My
text 2. My text 3.", "");
fld.SetFlag(Field::Flag::e_multiline, true);
Annot txt_box = Annot::CreateWidget(pdfdoc, Rect(50, 550, 350, 600),
fld);

// Add the annotation to a given page
page.AnnotPushBack(txt_box);

// Merge the annotation with the page content
fld.RefreshAppearance();
fld.FlattenField(page);

Code for C#, JAVA, VB.NET would be along the same lines.