Example: The following example will place three bookmarks on the PDF document. Each bookmark has a different action. The first bookmark links to a URL and when clicked on will open up that URL in the current window. The second bookmark when clicked will zoom the page to fit the width of that page. The third bookmark when clicked will bring the specified X, Y destination into focus. If that destination location is already visible no action is taken.
import com.cete.dynamicpdf.*; import com.cete.dynamicpdf.pageelements.*; public class MyClass{ public static void main(String args[]){ // Create a PDF Document Document document = new Document(); // Create three page objects Page page1 = new Page(PageSize.LETTER); Page page2 = new Page(PageSize.LETTER); Page page3 = new Page(PageSize.LETTER); // Add a top level Outline Outline parentOutline = document.getOutlines().add("Parent Outline"); // Add a top level bookmark page1.getElements().add(new Bookmark("Top level bookmark to page 1", 0, 0)); // Add child bookmarks page1.getElements().add( new Bookmark("Bookmark to page 1", 0, 0, parentOutline)); page2.getElements().add( new Bookmark("Bookmark to page 2", 0, 0, parentOutline)); page3.getElements().add( new Bookmark("Bookmark to page 3", 0, 0, parentOutline)); // Add the three pages to the document document.getPages().add(page1); document.getPages().add(page2); document.getPages().add(page3); // Save the PDF document document.draw("[PhysicalPath]/MyDocument.pdf"); } }