fuxialexander / org-pdftools

A custom org link type for pdf-tools
GNU General Public License v3.0
331 stars 35 forks source link
emacs org-mode pdf-tools

+TITLE: org-pdftools: a custom org link type for pdf-tools

This project was inspired by and built upon ~org-pdfview~ from @markus1189.

You can now install ~org-pdftools~ and ~org-noter-pdftools~ from MELPA!

[[https://melpa.org/#/org-pdftools][file:https://melpa.org/packages/org-pdftools-badge.svg]]

[[https://melpa.org/#/org-pdftools][file:https://melpa.org/packages/org-noter-pdftools-badge.svg]]

Run ~M-x pdf-tools-install~ after installation of ~pdftools~ if you haven't done before.

+BEGIN_SRC elisp

(use-package org-noter :config ;; Your org-noter config ........ (require 'org-noter-pdftools))

(use-package org-pdftools :hook (org-mode . org-pdftools-setup-link))

(use-package org-noter-pdftools :after org-noter :config ;; Add a function to ensure precise note is inserted (defun org-noter-pdftools-insert-precise-note (&optional toggle-no-questions) (interactive "P") (org-noter--with-valid-session (let ((org-noter-insert-note-no-questions (if toggle-no-questions (not org-noter-insert-note-no-questions) org-noter-insert-note-no-questions)) (org-pdftools-use-isearch-link t) (org-pdftools-use-freepointer-annot t)) (org-noter-insert-note (org-noter--get-precise-info)))))

;; fix https://github.com/weirdNox/org-noter/pull/93/commits/f8349ae7575e599f375de1be6be2d0d5de4e6cbf (defun org-noter-set-start-location (&optional arg) "When opening a session with this document, go to the current location. With a prefix ARG, remove start location." (interactive "P") (org-noter--with-valid-session (let ((inhibit-read-only t) (ast (org-noter--parse-root)) (location (org-noter--doc-approx-location (when (called-interactively-p 'any) 'interactive)))) (with-current-buffer (org-noter--session-notes-buffer session) (org-with-wide-buffer (goto-char (org-element-property :begin ast)) (if arg (org-entry-delete nil org-noter-property-note-location) (org-entry-put nil org-noter-property-note-location (org-noter--pretty-print-location location)))))))) (with-eval-after-load 'pdf-annot (add-hook 'pdf-annot-activate-handler-functions #'org-noter-pdftools-jump-to-note)))

+END_SRC

When browsing a pdftools-buffer you can use =org-store-link= (by default =C-c l=) to get a link to this location withing the pdf -- even while marking some content in the .pdf. Then use =org-insert-link= (by default =C-c C-l=) to create a link to this page and this place on the page:

+begin_example

[[pdf:~/file.pdf::5++0.00;;annot-5-0][file.pdf: Page 5; Quoting: some text]]

+end_example