We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Formatting issues with form field

I am tring to generate a document with Aspose Word 2.0 (java version) which will have some form field and simple formatting like Bold, italics, underline etc.
Formatting appear correctly in all the places except Form Fields.
I am attaching simplified version of my application code and the output of this program.

If you see the last line of output to be totally underlined, but form field is not taking that format.
Is it a bug in aspose or I am doing something wrong?


import com.aspose.words.Document;
import com.aspose.words.DocumentBuilder;
import com.aspose.words.FormField;
import com.aspose.words.FormFields;
import com.aspose.words.SaveFormat;
import com.aspose.words.TextFormFieldType;
import com.aspose.words.Underline;

public class FormatTest
    private DocumentBuilder builder = null;
    public static void main(String[] args) {
            System.out.println("----------Starting Test -----------");
            FormatTest t = new FormatTest();
            System.out.println("----------Ending Test -----------");

        catch (Throwable e)
            System.out.println("----------Oppppppppppps Somethings goes wrong here Start-----------");
            System.out.println("----------Oppppppppppps Somethings goes wrong here End-----------");


    private void testFormFieldAddition() throws Exception
        Document src = new Document("C:/data/formField.doc");
        FormFields flds = src.getRange().getFormFields();
        builder = new DocumentBuilder(src);

        builder.insertTextInput("fieldName", TextFormFieldType.REGULAR_TEXT,"","TBP",0);
        FormField f = flds.get("fieldName");
        f.setResult("Copy of 6359");


    void insertPreText() throws Exception
        builder.write(" Here is pre text ");

    void insertPostText() throws Exception
        builder.write(" Here is post text");

Thank you for posting. It actually behaves strange. I have logged it as issue #1381, we will try to investigate it shortly.

Also please consider the following thread, it seems devoted to a similar problem and contains some workarounds:
<A href="

I think this was fixed several versions ago. Please download latest Aspose.Words and try. Let us know if this still does not work for you.

We have released a new version of Aspose.Words that contains a fix for your issue.
The new version of Aspose.Words is available for download from here.
Best regards.