Are you a Java Developer working with PDF files?

Find out why you should be using JPedal

How to copy bookmarks from one PDF to another

32 sec read

How to copy bookmarks from one PDF to another

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

  1. 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();
  2. Then, write the Document object to the destination PDF:
    // Write
    final OutlineWriter writer = new OutlineWriter("destination.pdf", outlines);
    writer.writeOutline();
  3. 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.



The JPedal PDF library allows you to

Display PDF files in Java Apps
View PDF files in Java
Convert PDF Files to image