To
insert bookmarks in a pdf file first you have to create a simple text
file which will represent the structure of your bookmarks using your
favorite plain text editor, each line of text is a bookmark item
written in the form:
Chapter 1. The Beginning/23
Para 1.1 Child of The Beginning/25,FitWidth,96
Para 1.1.1 Child of Child of The Beginning/26,FitHeight,43
Chapter 2. The Continue/30,TopLeft,120,42
Para 2.1 Child of The Beginning/32,FitPage
where the part on the left of the '/' character is the title of
the bookmark and the part on the right is the target page of the
bookmark. The page number is optionally followed by comma separated
values, the first parameter is the fit type used for the bookmarks. If
this type is TopLeft then other two parameters are necessary, the top
and left offsets in thousandths of the page height and width (zoom
factor will be inherited), if the type is FitWidth only the top offset
is necessary while if the fit type is FitHeight only the left offset
must be specified. The type FitPage doesn't need any other parameter.
If no parameter follows the page number then FitWidth is assumed with
no offset. Text indentation represents the hierarchy of the outlines
and must be obtained with "tab characters" (spaces will not work). Once
you have the file, save it to the same folder where you have the pdf
file it refers to with a name like bookmarks.txt, then assuming that
the original pdf name is input.pdf and that we want to save modified
pdf as output.pdf, launch the command:
jpdfbookmarks --apply input.pdf
bookmarks.txt output.pdf
If output.pdf already exists or if you indicate input.pdf as output
file, the program will print a warning and ask for confirmation before
overwriting, i suggest that you never overwrite existing files to avoid
data loss.
Starting from version 1.2.3, you can apply the bookmarks from a
text file using the graphical user interface, from the Tools menu
select the "Load Bookmarks" command and choose the text file that
contains the bookmarks structures.
Warning: all the existing bookmarks in
the original pdf will be lost with this command!