dalanicolai / pymupdf-mode.el

Extend pdf-tools annotation capabilities via pymupdf
20 stars 0 forks source link

pymupdf-mode launches a python REPL in a comint buffer and imports the [[https://pymupdf.readthedocs.io/en/latest/][pymupdf]] library. Subsequently it uses elisp to send python commands to the comint buffer. At the moment it mainly provides a template for the user that can be completely modified (i.e. customized) using the excellent [[https://pymupdf.readthedocs.io/en/latest/][pymupdf]] documentation, especially its [[https://pymupdf.readthedocs.io/en/latest/faq.html#annotations][annotation]] section. Because pdf-tools recognizes these annotations naturally, the annotations are editable with pdf-tools which is awesome! [[./pymupdf-mode-demo.gif]]

Additionally, pymupdf contains functionality to quickly edit the pdf metadata (see [[Usage]])

** Comment The script has been tested on GNU/linux only, but it should work on any platform where python is installed.

The script is just a hack and things can act a little weird if not used in the correct way, especially when mixing pymupdf annotations with pdf-tools annotation functionality (although not much can go wrong).

** Related [[https://github.com/dalanicolai/pdf-continuous-scroll-mode.el][pdf-continuous-scroll-mode]] (HACK) \ [[https://github.com/dalanicolai/djvu2.el][djvu2]] (Experimental)

** Spacemacs Spacemacs users can install the package by adding the following lines to the list of additional packages in their dotfile (although this will overwrite any customizations on any package update):

+begin_src elisp

 (pymupdf-mode :location (recipe
                          :fetcher github
                          :repo "dalanicolai/pymupdf-mode.el"))

+end_src

Subsequently load the package by placing the following line in the user-config section of your dotfile:

+begin_src elisp

 (with-eval-after-load 'pdf-view
   (require 'pymupdf-mode))

+end_src

** Keybindings mouse-1 is left button mouse-3 is right button | =C-S-mouse-1= | pymupdf-draw-caret | | =C-S-drag-mouse-1= | pymupdf-draw-arrow | | =C-S-drag-mouse-3= | pymupdf-draw-free-text | *** Spacemacs (pdf-view-mode) | =, t c= | toggle pymupdf-mode |