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

Free Support Forum - aspose.com

Retrieve the shape contained in a bookmark

Hi, I would like to retrieve the shape contained in a bookmark, such as a graph. How can I do?

Bookmark bookmark = doc.getRange().getBookmarks().get("ID41_ATTUALE");			
Shape shape = (Shape) bookmark.getBookmarkStart().getAncestor(NodeType.SHAPE);
    			
if(shape.hasChart()) {
    Chart chart = shape.getChart();
    ChartAxis xAxis = chart.getAxisY();
    xAxis.getScaling().setMinimum(new AxisBound(100.0)); 
    xAxis.getScaling().setMaximum(new AxisBound(700.0));
}

But this following code, doesn’t work

TEST.docx (58.4 KB)

@Blegork BookmarkStart and Shape nodes are on the same level and are siblings. See the screenshot attached image.png (63.3 KB).
So to get the shape you should use code like the following:

Bookmark bookmark = doc.getRange().getBookmarks().get("ID41_ATTUALE");
Shape shape = (Shape) bookmark.getBookmarkStart().getNextSibling();
1 Like