Hi
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) {
try
{
System.out.println("----------Starting Test -----------");
FormatTest t = new FormatTest();
t.testFormFieldAddition();
System.out.println("----------Ending Test -----------");
}
catch (Throwable e)
{
System.out.println("----------Oppppppppppps Somethings goes wrong here Start-----------");
System.out.println(e.getMessage());
e.printStackTrace();
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.moveToDocumentEnd();
insertPreText();
builder.insertTextInput("fieldName", TextFormFieldType.REGULAR_TEXT,"","TBP",0);
FormField f = flds.get("fieldName");
f.setResult("Copy of 6359");
f.setOwnHelp(true);
f.setHelpText("helpText");
insertPostText();
src.save("C:/data/out.doc",SaveFormat.FORMAT_DOCUMENT);
}
void insertPreText() throws Exception
{
builder.setUnderline(Underline.SINGLE);
builder.write(" Here is pre text ");
}
void insertPostText() throws Exception
{
builder.write(" Here is post text");
builder.setUnderline(Underline.NONE);
}
}