How to set style for fields

Hi,

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:
http://www.aspose.com/docs/display/wordsjava/StyleType

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)
((Run)node).getFont().setSize(24);
}

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

I hope, this helps.

Best regards,