Free Support Forum - aspose.com

Bookmark how to change style, size, spaceAfter

Could you help me to do that? I want change bookmark’s style / font size / spaceAfter

Case ↓

private void drawOverview(Document doc, DocumentBuilder builder, String bookMarkName, MapList dataMapList)
throws Exception {

	String overview = "";
	for (int ii = 0; ii < dataMapList.size(); ii++) {
		overview += dataMapList.get(ii) + "\n";
	}

	Bookmark bookmark = doc.getRange().getBookmarks().get(bookMarkName);
	BookmarkInfoPrinter bookmarkVisitor = new BookmarkInfoPrinter();
	
	Run run = new Run(doc);
	if (bookmark != null) {
		bookmark.setText(overview);
		bookmark.getBookmarkStart().accept(bookmarkVisitor);
		
		run.getFont().setSize(10.0);
		run.getFont().setName("Arial");
		
		
		bookmark.getBookmarkEnd().accept(bookmarkVisitor);
		
		run.accept(bookmarkVisitor);
	}

}

public static class BookmarkInfoPrinter extends DocumentVisitor {
public int visitBookmarkStart(BookmarkStart bookmarkStart) throws Exception {
logger.debug("****" + bookmarkStart.getName() + " ,"+ bookmarkStart.getBookmark().getText());
return VisitorAction.CONTINUE;
}

	public int visitBookmarkEnd(BookmarkEnd bookmarkEnd) {
		logger.debug("****"+ bookmarkEnd.getName());
		return VisitorAction.CONTINUE;
	}
}

@sharon_wu

It seems like you are using Aspose.Words. Would you please confirm the Aspose API that you are using along with its version details? Also, please share sample source document along with expected output so that we can test the scenario in our environment and address it accordingly.