@saurabh.arora,
Thanks for your inquiry. Please refer to the following articles:
Use DocumentBuilder to Insert Document Elements
Using DocumentBuilder to Modify a Document
Please check the following code example. Hope this helps you. If you still face problem, please share your expected output Word document here for our reference. We will investigate how you want your final Word output be generated like. We will then provide you more information on this along with code.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.moveToHeaderFooter(HeaderFooterType.FOOTER_PRIMARY);
builder.getFont().setSize(10);
builder.getFont().setBold(true);
builder.write("Some text");
TabStop tab = new TabStop(6.27 * 72, TabAlignment.RIGHT, TabLeader.NONE);
builder.getParagraphFormat().getTabStops().add(tab);
builder.write(ControlChar.TAB);
builder.getFont().setSize(15);
builder.getFont().setBold(false);
builder.getFont().setItalic(true);
builder.insertField(FieldType.FIELD_PAGE, false);
builder.write(" of ");
builder.insertField(FieldType.FIELD_NUM_PAGES, false);
doc.updateFields();
doc.save(MyDir + "Out.docx");