Aspose.Words

Document doc = new Document("data/Aspose_Bookmark.doc");

// By name.
Bookmark bookmark = doc.getRange().getBookmarks().get("AsposeBookmark");
bookmark.remove();

Docx4j

WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage
		.load(new java.io.File("data/Docx4j_BookmarkAdd.docx"));
MainDocumentPart documentPart = wordMLPackage.getMainDocumentPart();

// Before..
// System.out.println(XmlUtils.marshaltoString(documentPart.getJaxbElement(), true, true));

org.docx4j.wml.Document wmlDocumentEl = (org.docx4j.wml.Document) documentPart
		.getJaxbElement();
Body body = wmlDocumentEl.getBody();

fixRange(body.getContent(), "CTBookmark", "CTMarkupRange");

// After
System.out.println(XmlUtils.marshaltoString(documentPart.getJaxbElement(), true, true));

wordMLPackage.save(new java.io.File("data/Docx4jBookmarkDeleted.docx"));


Download Source Code

For More Examples, Please Visit Aspose Docs

Last edited Aug 6, 2014 at 4:32 PM by asposemarketplace, version 1