I would like to be able to insert into an org-buffer the text extracted from a pdf file. PDF-Tools (
https://github.com/politza/pdf-tools/) provides some excellent tools for doing this. I've written (well, msotly stolen) a defun that finds all my highlights and returns them in the form of an org heading:
(defun pdf-annot-export-as-org-heading (pdfpath)
"Acquire highlight annotations as text, and insert into existing buffer as org heading"
(interactive)
(let ((outputstring "")
)
(save-excursion
(find-file pdfpath)
(let (
(annots (sort (pdf-annot-getannots nil (list 'highlight) nil) 'pdf-annot-compare-annotations))
(filename (format "%
s.org"
(file-name-sans-extension
(buffer-name))))
(linktext (concat "[[file://" (buffer-file-name)
"][" (file-name-sans-extension (buffer-name)) "]]" )))
(setq outputstring (concat "** " (file-name-sans-extension (buffer-name)) "\n\n"))
;; (insert (concat "#+TITLE: Notes for " (file-name-sans-extension filename)))
;; (org-insert-heading-respect-content)
;; (insert (file-name-sans-extension filename))
(mapc
(lambda (annot) ;; traverse all annotations
(message "%s" annot)
(let ((page (assoc-default 'page annot))
(text (assoc-default 'subject annot))
)
;;(insert (concat "\n" text " (" linktext ", " (number-to-string page) ")\n"))
(setq outputstring (concat outputstring text " (" linktext ", " (number-to-string page) ")\n\n"))
)
)
annots)
))
;;(write-file filename t)
outputstring
))
-------------
I'm sure it is very clumsy, but it sort of works. I would like to be able to call this function from a source block:
(pdf-annot-export-as-org-heading "/home/matt/HackingHistory/readings/latour-pandoras-hope.pdf")
(pdf-annot-export-as-org-heading "/home/matt/HackingHistory/readings/historical-authority-hampton.pdf")