pdftk is GOAT
Source: Dev.to
Introduction
I need a free, open‑source PDF editor for Linux. Previously I used a Foxit Editor subscription on Windows just to edit PDF bookmarks, even though I work on Linux daily. A quick search led me to pdftk, which turned out to be an absolute masterpiece for handling PDF metadata.
Dump PDF metadata
pdftk random.pdf dump_data_utf8 output output.txt
This command extracts the PDF’s metadata (including bookmarks) into output.txt.
Edit bookmarks
Open output.txt and locate the BookmarkBegin sections. Edit the existing entries or, if a bookmark is missing, append a new block at the end of the file—one block per bookmark:
BookmarkBegin
BookmarkTitle: Bookmark Title
BookmarkLevel: 1
BookmarkPageNumber: 1
Save the file after making your changes.
Apply the new metadata
pdftk random.pdf update_info_utf8 output.txt output output.pdf
This command writes the edited metadata back into the PDF, producing output.pdf.
Using pdftk is far faster than my previous workflow.