)
{
Pages pages = document.getPages();
// Bookmarks.
Bookmarks bookmarks = new Bookmarks(document);
document.setBookmarks(bookmarks);
document.setPageMode(PageModeEnum.Bookmarks);
Page page = pages.get(0);
Bookmark rootBookmark = new Bookmark(
document,
"Creation Sample",
new LocalDestination(
page,
Destination.ModeEnum.Fit,
null
)
);
bookmarks.add(rootBookmark);
bookmarks = rootBookmark.getBookmarks();
page = pages.get(1);
Bookmark bookmark = new Bookmark(
document,
"2nd page (close-up view)",
new LocalDestination(
page,
Destination.ModeEnum.XYZ,
new Float[]{0f,250f,2f}
)
);
bookmarks.add(bookmark);
bookmark.getBookmarks().add(
new Bookmark(
document,
"2nd page (mid view)",
new LocalDestination(
page,
Destination.ModeEnum.XYZ,
new Float[]{0f,(float)page.getSize().getHeight() - 250,1f}
)
)
);
page = pages.get(2);
bookmarks.add(
new Bookmark(
document,
"3rd page (fit horizontal view)",
new LocalDestination(
page,
Destination.ModeEnum.FitHorizontal,
new Float[]{0f}
)
)
);
try
{
bookmarks.add(
bookmark = new Bookmark(
document,
"PDF Clown Home Page",
new GoToURI(document, new URI("http://www.pdfclown.org"))
)