Create Form in document

Hi,

  1. How to create a document in the following format:

First Name: Text box to enter data

Last Name: Textbox to enter data

  1. When to use sections and when to use paragraphs?

  2. I’ve seen examples to create documents some with Document object model some are using DocumentBuilder. Which is the preferred and recommended approach in creating word documents?

Thanks in advance

Any example on how to do the number 1 above?

Hi,

Thanks for your inquiry. You can achieve your requirement by creating text form field. Please use following code snippet for your requirement.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.InsertTextInput("TextInput", TextFormFieldType.Regular, "", "Hello", 0);
doc.UpdateFields();
doc.Save(MyDir + "AsposeOut.docx");

Please read following documentation link for your requirments.
https://docs.aspose.com/words/net/working-with-form-fields/

Section class represents a single section in a document and Paragraph class represents a paragraph of text. Paragraph is a block-level node and can be a child of classes derived from Story or InlineStory. Paragraph can contain any number of inline-level nodes and bookmarks.

Document class represents a Word document. The Document is a central object in the Aspose.Words library. DocumentBuilder class provides methods to insert text, images and other content, specify font, paragraph and section formatting.

Please let us know if you have any more queries.