How to Delete Bookmarks in PDF using Java

This short tutorial explains how to delete bookmarks in PDF using Java. It provides the details to establish the environment, program flow, and a runnable sample code to remove bookmarks in PDF using Java. It also shares information to delete selected bookmark(s) according to user-defined criteria.

Steps to Remove Bookmark from PDF using Java

  1. Set the development environment to use Aspose.PDF for Java to remove bookmarks
  2. Load the source PDF file into the Document object having a few bookmarks in it
  3. Call the OutlineCollection.delete() method to delete all the bookmarks
  4. Save the resultant PDF file without bookmarks on the disk

These steps elaborate on how to delete bookmarks in Adobe PDF using Java. In the first step, the source PDF file with bookmarks is loaded into the document class object, and subsequently the getOutlines().delete() method is called from the Document class to delete all the bookmarks. Once the bookmarks are deleted, the output PDF file is saved on the disk.

Code to Delete Bookmarks in PDF using Java

This code snippet demonstrates how to remove bookmarks in PDF using Java. It contains a call to the delete() method without any argument that deletes all the bookmarks. If you want to delete a particular bookmark, you may use the other overload of the delete() method that takes the bookmark name that is to be deleted.

This tutorial has guided us on how to remove bookmark from pdf using java. If you want to learn the process of reading bookmarks from a PDF file, refer to the article on how to read bookmarks in PDF using Java.

 English