Adding form field to Word with Spire .DOC

Technical support for Spire.Doc

Moderator: iceblue support

Adding form field to Word with Spire .DOC

Postby james » Tue Jan 04, 2011 2:37 am

Hello, :lol:
Can I add form field to Word with your product? :roll:
And what formats does it support?
THANKS! :P
james
 
Posts: 8
Joined: Tue Dec 21, 2010 9:29 am

Re: Adding form field to Word with Spire .DOC

Postby iceblue support » Tue Jan 04, 2011 10:01 am

Thank you for your inquiry.
Yes, you can add form field with Spire .DOC.
The Spire .DOC supports TextFormField, CheckBoxFormField, DropDownFormField.
e-iceblue support
User avatar
iceblue support
 
Posts: 244
Joined: Tue Dec 21, 2010 2:56 am

Re: Adding form field to Word with Spire .DOC

Postby Finalsky » Wed Jan 05, 2011 8:58 am

How can I choose options of DropDownFormField, how to check the box from the field and how to fill text in the field?
Finalsky
 
Posts: 13
Joined: Wed Dec 22, 2010 1:12 am

Re: Adding form field to Word with Spire .DOC

Postby iceblue support » Wed Jan 05, 2011 10:23 am

Choose the options of the field:
"DropDownFormField combox = field as DropDownFormField;
for(int i = 0; i < combox.DropDownItems.Count; i++)
{
if (combox.DropDownItems[i].Text == ""your selected value"")
{
combox.DropDownSelectedIndex = i;
break;
}
}

Check the box of the field:
CheckBoxFormField checkBox = field as CheckBoxFormField;
checkBox.Checked = true;

Add text into the field:
TextFormField textInput = field as TextFormField;
textInput.Text = ""your text"";
e-iceblue support
User avatar
iceblue support
 
Posts: 244
Joined: Tue Dec 21, 2010 2:56 am

Re: Adding form field to Word with Spire .DOC

Postby wangjun » Sun Jan 04, 2015 2:02 am

How insert checkbox at fixed position, for example near by 'this a checkbox' character?
wangjun
 
Posts: 8
Joined: Wed Dec 31, 2014 8:42 am

Re: Adding form field to Word with Spire .DOC

Postby Gary.zhang » Mon Jan 05, 2015 7:13 am

Hello,

Sorry for late reply. MS Word document is flow document and does not contain any information about its layout into lines and pages. So there is no way to determine on which page and where on the page some particular node is located. Here is the method to insert checkbox near by 'this a checkbox' character for your reference.
Code: Select all
Document doc = new Document();
Section section = doc.AddSection();
Paragraph para1 = section.AddParagraph();
para1.AppendText("paragraph1");
Paragraph para2 = section.AddParagraph();
para2.AppendText("this a checkbox");
CheckBoxFormField cb = new CheckBoxFormField(doc);
cb.Checked = true;
cb.Name = "Chk1";
para2.Items.Insert(1, cb);
doc.SaveToFile("test.docx", FileFormat.Docx);

If there are any doubt, you could provide us your document and state your requirement, we will provide the corresponding demo for your reference.
Thanks,
Gary
E-iceblue support team
User avatar
Gary.zhang
 
Posts: 1390
Joined: Thu Apr 04, 2013 1:30 am


Return to Spire.Doc

Who is online

Users browsing this forum: No registered users and 0 guests