View Single Post
Old 05-02-2020, 08:50 AM   #5
willus
Fuzzball, the purple cat
willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.willus ought to be getting tired of karma fortunes by now.
 
willus's Avatar
 
Posts: 1,185
Karma: 9900210
Join Date: Jun 2011
Location: California
Device: iPad
Quote:
Originally Posted by Tex2002ans View Post
Many many years ago I used jpdfbookmarks:

http://flavianopetrocchi.blogspot.co...marks-252.html

Edit: I just looked up and saw that willus's fantastic tool, k2pdfopt also has an option "-toclist".

This allows you to create a simple text file:

Code:
1 Introduction
10 Chapter 1
+10 Chapter 1, Part A
+25 Chapter 1, Part B
++25 Chapter 1, Part B, Subsection 1
++27 Chapter 1, Part B, Subsection 2
+30 Chapter 1, Part C
50 Chapter 2
70 Chapter 3
and insert that as PDF bookmarks.

You can read more details in his "List of Command-Line Options" (and check the above thread too, willus has tons of answers about his program there).
If all you need to do is add a TOC/bookmarks, Coherent PDF (cpdf) is a better tool than k2pdfopt. It's an excellent PDF command-line tool to have in your arsenal--it can split, merge, add watermarks, etc., and it's super fast. See this link.

To list existing bookmarks:

cpdf -list-bookmarks input.pdf

0 "Part 1" 1 open
1 "Part 1A" 2
2 "Part 1B" 3
0 "Part 2" 4
1 "Part 2a" 5


I presume "open" is the bookmark you want the file to open to by default.

To add bookmarks:

cpdf -add-bookmarks bookmarks.txt input.pdf -o output.pdf
willus is offline   Reply With Quote