Insert HTML with custom page number into Aspose word using Java

Hi I am trying to insert custom page numbers in each page header on aspose word. The header is HTML-based so need to insert custom page numbers on specific location. I am using the reference from the ticket Insert HTML with custom page number into document using .NET but it’s not working for java. THe html stated there is as following

	<p style="margin-top:0pt; margin-bottom:0pt; font-size:12pt">
		<span style="-aw-field-start:true"></span><span style="-aw-field-code:' PAGE   \\* MERGEFORMAT '"></span><span style="-aw-field-separator:true"></span><span style="font-family:'Times New Roman'">1</span><span style="-aw-field-end:true"></span>
	</p>
	<p style="margin-top:0pt; margin-bottom:0pt; font-size:12pt">
		<span style="-aw-field-start:true"></span><span style="-aw-field-code:' NUMPAGES   \\* MERGEFORMAT '"></span><span style="-aw-field-separator:true"></span><span style="font-family:'Times New Roman'">1</span><span style="-aw-field-end:true"></span>
	</p>

Should the same snippet work in java as well?

Thanks, Regards

@Awais65 Yes, the same works for Java too. I used the following simple code for testing - PAGE and NUMPAGES fields are properly inserted in the the document’s header:

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

builder.moveToHeaderFooter(HeaderFooterType.HEADER_PRIMARY);

builder.insertHtml("\t<p style=\"margin-top:0pt; margin-bottom:0pt; font-size:12pt\">\n" +
        "\t\t<span style=\"-aw-field-start:true\"></span><span style=\"-aw-field-code:' PAGE   \\\\* MERGEFORMAT '\"></span><span style=\"-aw-field-separator:true\"></span><span style=\"font-family:'Times New Roman'\">1</span><span style=\"-aw-field-end:true\"></span>\n" +
        "\t</p>\n" +
        "\t<p style=\"margin-top:0pt; margin-bottom:0pt; font-size:12pt\">\n" +
        "\t\t<span style=\"-aw-field-start:true\"></span><span style=\"-aw-field-code:' NUMPAGES   \\\\* MERGEFORMAT '\"></span><span style=\"-aw-field-separator:true\"></span><span style=\"font-family:'Times New Roman'\">1</span><span style=\"-aw-field-end:true\"></span>\n" +
        "\t</p>");

doc.save("C:\\Temp\\out.docx");

Could you please create an expected output document in MS Word and attach it here? we will check it and provide you more information.