Cant able to set font style for DATE field

HI,

I am using Aspose latest version for document conversion. I tried to insert DATE field and apply some font styles to it as below

 Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);
builder.moveToDocumentEnd();

Field fld = builder.insertField("AUTHOR", "Test"); //No i18n

FieldSeparator fldSp = fld.getSeparator();
Run run = (Run) fldSp.getNextSibling();
run.getFont().setName("impact");
run.getFont().setBold(true);

Field fld2 = builder.insertField("DATE", "March 23, 2013"); //No i18n

fldSp = fld2.getSeparator();
run = (Run) fldSp.getNextSibling();
run.getFont().setName("impact");
run.getFont().setBold(true);

fld.update();

doc.save("out.docx", SaveFormat.DOCX);

After conversion. I can able to see the font style for AUTHOR field not for DATE field.
Am i doing anything wrong ?

Please help me

Hi Anbu,

Thanks for your inquiry. Please try run the following code snippet to be able to achieve what you need:
...

.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.moveToDocumentEnd();

builder.getFont().setName("impact");

builder.getFont().setBold(true);

Field fld = builder.insertField("AUTHOR", "Test"); //No i18n

FieldSeparator fldSp = fld.getSeparator();

Run run = (Run) fldSp.getNextSibling();

.

.
I hope, this helps.

Best regards,

Thanks for the reply.
Actually you are trying to apply bold for the whole paragraph.
What i need to do is bold the date field alone.
like this

Date : 31-May-2013 ,

Hi Anbu,

Thanks for your inquiry. To achieve this, you can find all Run nodes i.e. contained inside FieldStart and FieldEnd characters and set their Font.Bold property as follows:

Field fld2 = builder.insertField("DATE", "March 23, 2013");
Node currentNode = fld2.getStart();

boolean isContinue = true;
while (currentNode != null && isContinue)
{
    if (currentNode.getNodeType() == NodeType.FIELD_END)
        isContinue = false;

    if (currentNode.getNodeType() == NodeType.RUN)
        ((Run)currentNode).getFont().setBold(true);

    Node nextNode = currentNode.nextPreOrder(currentNode.getDocument());
    currentNode = nextNode;
}

I hope, this helps.

Best regards,