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

Free Support Forum - aspose.com

How to set style for fields


How to insert field( like : pageNum , num of pages ) in paragraph and set style for field like incresing font size and color ?

Hi Anbu,

Thanks for your inquiry. There are few types of styles – Paragraph styles, Character styles, List styles and Table styles. To learn about different style types, please refer to the following article:

You can apply same character type style on each Run belonging to a particular field.

Best regards,

Hi awais ,

Thanks for your quick response . Actually i want to increase the size for the Field ( PAGE and PAGE NUMBER ) can you please help me with the code .

Hi Anbu,

Thanks for your inquiry. You can use the following code to increase the font size of a field:
Document doc = new Document(getMyDir() + “in.docx”);

NodeCollection fields = doc.getChildNodes(NodeType.FIELD_START, true);
FieldStart fieldStart = (FieldStart)fields.get(0);

for (Node node = fieldStart; node != null && node.getNodeType() != NodeType.FIELD_END; node = node.nextPreOrder(node.getDocument()))
if (node.getNodeType() == NodeType.RUN)

doc.save(getMyDir() + “out.docx”);

I hope, this helps.

Best regards,