Search in sources :

Example 1 with Bookmarks

use of org.apache.poi.hwpf.usermodel.Bookmarks in project poi by apache.

the class HWPFLister method dumpBookmarks.

private void dumpBookmarks() {
    if (!(_doc instanceof HWPFDocument)) {
        System.out.println("Word 95 not supported so far");
        return;
    }
    HWPFDocument document = (HWPFDocument) _doc;
    Bookmarks bookmarks = document.getBookmarks();
    for (int b = 0; b < bookmarks.getBookmarksCount(); b++) {
        Bookmark bookmark = bookmarks.getBookmark(b);
        System.out.println("[" + bookmark.getStart() + "; " + bookmark.getEnd() + "): " + bookmark.getName());
    }
}
Also used : HWPFDocument(org.apache.poi.hwpf.HWPFDocument) Bookmarks(org.apache.poi.hwpf.usermodel.Bookmarks) Bookmark(org.apache.poi.hwpf.usermodel.Bookmark)

Example 2 with Bookmarks

use of org.apache.poi.hwpf.usermodel.Bookmarks in project poi by apache.

the class TestBookmarksTables method test.

public void test() {
    HWPFDocument doc = HWPFTestDataSamples.openSampleFile("pageref.doc");
    Bookmarks bookmarks = doc.getBookmarks();
    assertEquals(1, bookmarks.getBookmarksCount());
    Bookmark bookmark = bookmarks.getBookmark(0);
    assertEquals("userref", bookmark.getName());
    assertEquals(27, bookmark.getStart());
    assertEquals(38, bookmark.getEnd());
}
Also used : HWPFDocument(org.apache.poi.hwpf.HWPFDocument) Bookmarks(org.apache.poi.hwpf.usermodel.Bookmarks) Bookmark(org.apache.poi.hwpf.usermodel.Bookmark)

Aggregations

HWPFDocument (org.apache.poi.hwpf.HWPFDocument)2 Bookmark (org.apache.poi.hwpf.usermodel.Bookmark)2 Bookmarks (org.apache.poi.hwpf.usermodel.Bookmarks)2