JPedal already has the ability to read bookmarks from PDF files so now you can chain this functionality with our OutlineWriter to copy bookmarks from one PDF to another.
Recently we released JPedal 2023.03 which includes the ability to write bookmarks (also known as the outline) to PDF files. You can download JPedal here to try for yourself.
Copy bookmarks using Java
First, read the outline into a Document object:
// Read final ExtractOutline extract = new ExtractOutline("source.pdf"); extract.openPDFFile(); final Document outlines = extract.getPDFTextOutline(); extract.closePDFfile();
Then, write the Document object to the destination PDF:
// Write final OutlineWriter writer = new OutlineWriter("destination.pdf", outlines); writer.writeOutline();
Copy bookmarks using the command line
JPedal also provides a convenient command line method to copy bookmarks between PDF files:
java -jar jpedal.jar --copyoutline "oldfile.pdf" "newfile.pdf"
Learn more
More information is available on our support site.
Download JPedal here to get started.