Free Support Forum - aspose.com

Insert FormField

Dear Sir

I want to insert a formfield in my document with a specific font and in some case put a text before it .I could do it by code below but not completely.First of all the font property doesn't work and second the text doesn't insert before formfield.

Here is piece of my code,Please tell me why it doesn't work very well?

Thanks

Mehi Mokhtari

builder.MoveToSection(m_document.IndexOf(objsection))

newField = builder.InsertTextInput("Subject", Fields.TextFormFieldType.RegularText, "", "", 0)

newField.TextInputType = Fields.TextFormFieldType.RegularText

newField.Font.Size = PrpFontSize

newField.Font.SizeBi = PrpFontSize

newField.Font.NameBi = PrpFontName

newField.Font.Name = PrpFontName

newField.Name = "Subject"

newField.Font.Bidi = True

newField.Result = " تاتاتاات"

newField.Enabled = Enabled

If WithText Then

Dim Run As New Run(m_document)

Run.Text = "موضوع : "

Run.Font.NameBi = PrpFontName

Run.Font.Name = PrpFontName

Run.Font.Size = PrpFontSize

Run.Font.SizeBi = PrpFontSize

Run.Font.Bidi = True

objsection.Body.Paragraphs(0).InsertBefore(Run, newField)

End If

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. Please try using the following code.

builder.MoveToSection(m_document.IndexOf(objsection))

builder.Font.Name = PrpFontName

builder.Font.Size = PrpFontSize

builder.Font.NameBi = PrpFontName

builder.Font.SizeBi = PrpFontSize

builder.Font.Bidi = True

If WithText Then

builder.Write("موضوع : ")

End If

newField = builder.InsertTextInput("Subject", Fields.TextFormFieldType.RegularText, "", "", 0)

newField.Name = "Subject"

newField.Result = " تاتاتاات"

newField.Enabled = Enabled

Hope this helps.

Best regards.

Dear Sir

Thanks for your reply.I could do it with your guid but I still have problem.I want to set direction of my section Right-to-Left and also Align Right with the highlighted code but it doesn't work .

Please,tell me how could I do it?

Thanks

Mehdi Mokhtari

builder.MoveToSection(m_document.IndexOf(objsection))<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

builder.Font.Name = PrpFontName

builder.Font.Size = PrpFontSize

builder.Font.NameBi = PrpFontName

builder.Font.SizeBi = PrpFontSize

builder.Font.Bold = BoldStyle

builder.Font.BoldBi = BoldStyle

builder.Font.Italic = ItalicStyle

builder.Font.ItalicBi = ItalicStyle

builder.Font.Bidi = True

builder.ParagraphFormat.Alignment = ParagraphAlignment.Right

builder.RowFormat.Alignment = Tables.RowAlignment.Right

builder.ParagraphFormat.Bidi = True

builder.RowFormat.Bidi = True

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. I think that you should also set PageSetup.Bidi property to true. See the following link for more information.

http://www.aspose.com/documentation/file-format-components/aspose.words-for-.net-and-java/aspose.words.pagesetup.bidi.html

Here is example

doc.FirstSection.PageSetup.Bidi = true;

Hope this helps.

Best regards.