Read PDF File to retrieve the bookmarks : Bookmarks « PDF « Java Tutorial






import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import com.lowagie.text.pdf.PdfReader;
import com.lowagie.text.pdf.SimpleBookmark;

public class HelloWorldBookmarks {
  public static void main(String[] args) throws Exception {
    PdfReader reader = new PdfReader("HelloWorldRead.pdf");
    List list = SimpleBookmark.getBookmark(reader);
    for (Iterator i = list.iterator(); i.hasNext();) {
      showBookmark((Map) i.next());
    }
  }

  private static void showBookmark(Map bookmark) {
    System.out.println(bookmark.get("Title"));
    ArrayList kids = (ArrayList) bookmark.get("Kids");
    if (kids == null)
      return;
    for (Iterator i = kids.iterator(); i.hasNext();) {
      showBookmark((Map) i.next());
    }
  }

}








29.33.Bookmarks
29.33.1.Add bookmark
29.33.2.Read PDF File to retrieve the bookmarks
29.33.3.Set bookmark title
29.33.4.Pdf SimpleBookmark
29.33.5.Copy book mark