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 PDFs can be troublesome. We have a list of different articles for you to understand the PDF format and maximise its functionality.
The JPedal PDF library allows you to solve these problems in Java
Viewer viewer = new Viewer();
viewer.setupViewer();
viewer.executeCommand(ViewerCommands.OPENFILE, "pdfFile.pdf");
//Convenience static method (see class for additional options)
ExtractClippedImages.writeAllClippedImagesToDir("inputFileOrDirectory", "outputDir", "outputImageFormat", new String[] {"imageHeightAsFloat", "subDirectoryForHeight"});
//Convenience static method (see class for additional options)
ExtractTextAsWordList.writeAllWordlistsToDir("inputFileOrDirectory", "outputDir", -1);
//Convenience static method (see class for additional options)
ArrayList resultsForPages = FindTextInRectangle.findTextOnAllPages("/path/to/file.pdf", "textToFind");
PrintPdfPages print = new PrintPdfPages("C:/pdfs/mypdf.pdf");
if (print.openPDFFile()) {
print.printAllPages("Printer Name");
}
//Convenience static method (see class for additional options)
ExtractClippedImages.writeAllClippedImagesToDir("inputFileOrDirectory", "outputDir", "outputImageFormat", new String[] {"imageHeightAsFloat", "subDirectoryForHeight"});
Why do developers choose JPedal over alternatives?
- Actively developed commercial library with full support and no third party dependencies.
- Simple licensing options and source code access for OEM users.
- Process PDF files up to 3x faster than alternative Java PDF libraries.