Index with page number

Please help on how to create index with page numbers. Thank you.

Hi,

Thanks for your inquiry. Could you please attach your input Word document and expected document here for our reference? We will investigate the structure of your expected document as to how you want your final output be generated like. You can create expected document using Microsoft Word. We will then provide you code to achieve the same using Aspose.Words.

Best regards,

Thank you for the reply.


Kindly find the attached sample document with page number index.

Thank you.

Hi,


Thanks for your inquiry. You can insert XE field using the following code:

Document doc = new Document(getMyDir() + “input.docx”);
DocumentBuilder builder = new DocumentBuilder(doc);

// Get paragraph you want to append this merge field to
Paragraph para = (Paragraph)doc.getChildNodes(NodeType.PARAGRAPH, true).get(1);

// Move cursor to this paragraph
builder.moveTo(para);

FieldXE field = (FieldXE)builder.insertField(FieldType.FIELD_INDEX_ENTRY, false);

field.setText(“Test1”);
field.isBold(true);
field.setEntryType(“Test2”);
field.isItalic(true);
field.setPageRangeBookmarkName(“Test3”);
field.setPageNumberReplacement(“Test4”);
field.setYomi(“Test5”);

doc.save(getMyDir() + “awjava-16.4.0.docx”);
Hope, this helps.

Best regards,

Sorry. I am not completely understand the solution. kindly could you please elaborate using my sample document that I attached. thank you.



Hi,


Thanks for your inquiry. Please refer to the following article:
Create an index and update an index

The operations, that you can perform using MS Word, can also be performed using Aspose.Words. Please refer to the code mentioned in my previous post. Also, please check documentation to learn how to insert different elements in document:
Inserting Document Elements

Best regards,