Coherent PDF Tools is a command line PDF tool for Windows, Mac and Unix. It is free for non-commercial use. I wanted to remove all bookmarks in the PDF file and re-edit them and Coherent PDF Tools can remove all bookmarks in single command. After some try, it simply worked. Here I introduce how to edit bookmarks with Coherent PDF Tools. This tutorial was tested on OS X 10.9.
Coherent PDF Tools is a single command line tool without external dependency, so just download the binary release and put it into execution path like /usr/local/bin.
Before editing bookmarks, dump out the bookmark file.
bookmarks.txt is a plain text file, the format looks like the following content:
Each single line presents one bookmark in PDF file. The first part means the hierarchy of bookmarks. The next bookmark should only be one layer deeper than the previous bookmark. The second part is the bookmark text showed in a PDF file. Text should be quoted with double quotation marks and no inner double quotation marks are allowed.
cpdf seems unable to escape double quotation marks. The final part is the page of the bookmark. Page number should be counted from the cover page and started from 1.
After editing bookmarks.txt, save back to the PDF file:
If any error occurs, the step will not succeed. Check bookmarks.txt for possible errors.
If you intend to delete all bookmarks on a PDF file, do this:
There are a lot thing can be done with Coherent PDF Tools, see their manual for the details.