Free Support Forum - aspose.com

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

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

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

<span lang=“EN-GB” style=“font-size:10.0pt;font-family:“Courier New”;color:#2B91AF;mso-font-kerning:
0pt;mso-no-proof:yes”>Document<span lang=“EN-GB” style=“font-size:10.0pt;
font-family:“Courier New”;mso-font-kerning:0pt;mso-no-proof:yes”> doc = new Document();<o:p></o:p>

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.
http://www.aspose.com/docs/display/wordsnet/Form+Fields+in+Aspose.Words

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.