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.
How to Copy bookmarks using Java
- Add JPedal to your class or module path. (download the trial jar).
- Next, 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"
Working with bookmarks in JPedal
If you are looking to work with Annotations in JPedal, we recommend you start with these tutorials:-
Working with PDFs can be troublesome. We have a list of different articles for you to understand the PDF format and maximise its functionality.