Free Support Forum - aspose.com

Get all heading from cross reference


#1

Hi Aspose-support team,

at the moment I am working on a cross reference table.
But I do need all reference “header” styles.
In Word, if you click “cross reference” -> “heading” then you can get all headers of the document.

I tried the following code, but it looks like not all reference are included:

Attached you can find the screenshot of the MS Word function I am talking about.

Thank you.

NodeCollection<Paragraph> nodes = doc.getChildNodes(NodeType.PARAGRAPH, true);

	for (Paragraph child : (Iterable<Paragraph>) nodes) {
		BookmarkCollection bookmarks = child.getRange().getBookmarks();

		for (Bookmark bookmark : bookmarks) {
			System.out.println("++" + bookmark.getName() + " = " + bookmark.getText().replaceAll("\\r", ""));

		}
	}

Thank You very much.
image.png (25.6 KB)


#2

@kai20511,

Please ZIP and attach your sample Word document here for testing. We will then investigate the scenario on our end and provide you more information.


#3

@awais.hafeez
I am sorry Awais,
The problem is fixed now…

My problem was, I was testing the Bookmark implementation in a new project first and did not had the license configured in this test project.
Therefore only the first entry’s where shown but not all.

If there would be sysout message, that Aspose is running in trial mode, then I would have found it before.
Ticket can be closed.

Thank you and best regards


#4

@kai20511,

The License.IsLicensed Property returns true if a valid license has been applied; false if the component is running in evaluation mode.

It is great that you were able to resolve this issue on your end. Please let us know anytime you have any further queries.