This Java programs adds a bookmark for every page in a PDF document using Qoppa’s library jPDFProcess.
// Load the document PDFDocument pdfDoc = new PDFDocument ("input.pdf", null); // Get the root bookmark, create one if necessary Bookmark rootBK = pdfDoc.getRootBookmark(); if (rootBK == null) { rootBK = pdfDoc.createRootBookmark (); } // Add a bookmark for every page for (int page = 0; page < pdfDoc.getPageCount(); ++page) { Bookmark bk = rootBK.addChildBookmark("Page " + (page + 1)); bk.addAction(new GotoPageAction (page+1)); } // Save the document pdfDoc.saveDocument ("output.pdf"); |