-
-
Save daanturo/010601e4910fbf0287df104b567a206d to your computer and use it in GitHub Desktop.
pdf-toc-gen.el
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(named-let recur ((files input-files) | |
(cur-page-num-counter 1) | |
(acc-bookmarks "")) | |
(cond | |
((seq-empty-p files) | |
acc-bookmarks) | |
(t | |
(-let* ((file (car files)) | |
(title (--> (file-name-base file) | |
(string-replace "_" " " it))) | |
(cur-file-bookmarks (format "BookmarkBegin | |
BookmarkTitle: %s | |
BookmarkLevel: 1 | |
BookmarkPageNumber: %d | |
" title cur-page-num-counter)) | |
(new-page-num-counter (+ cur-page-num-counter | |
(page-number-in-file file)))) | |
(message "Generating bookmarks for %s" file) | |
(recur (cdr files) | |
new_page_num_counter | |
(concat acc-bookmarks | |
cur-file-bookmarks | |
(shell-command-to-string | |
(format "pdf-my-demote-bookmarks %s %s" | |
file | |
(- cur-page-num-counter 1))))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment