DEV Community

Youssef Adly
Youssef Adly

Posted on

pdftk is GOAT

I am not aware of FOSS pdf editor for Linux (I really need one), and I had free subscription for Foxit Editor, sso I used to boot Windows just to edit PDF bookmarks (my dumb uni can't seem to add them), even though I daily-drive Linux.

I did a quick search, and I found pdftk, an absolute masterpiece

  1. Dump PDF metadata out
# input the pdf
pdftk random.pdf dump_data_utf8 output output.txt
Enter fullscreen mode Exit fullscreen mode
  1. Edit them

in output.txt grep for BookmarkBegin and start editing, if it is missing just append it at the end of the pdf (one block per bookmark)

BookmarkBegin
BookmarkTitle: Bookmark Title
BookmarkLevel: 1
BookmarkPageNumber: 1
Enter fullscreen mode Exit fullscreen mode

save your file

  1. apply the new metadata
pdftk random.pdf update_info_utf8 output.txt output output.pdf
Enter fullscreen mode Exit fullscreen mode

this so much more faster than old workflow tbh

Top comments (0)