pdf-drop-mode
is a convenient mode that search for the DOI of any file that is
dropped onto a buffer. To do that, the mode searches the DOI using several
different methods (whose order can be specified):
- Look at the file metadata to check if a DOI is attached using exiftool (whose path can be specified).
- Search the content of the file to try to locate a DOI regex on the first page (PDF is transformed into text using the pdftotext utility).
- Search again the metadata to try to find the title and query the crossref database to get a corresponding DOI.
- Ask the user to enter the title of the file and query the crossref database to try to get a correspondong DOI.
If all methods failed, then the search has failed. When search finishes, a user-defined function is called with the filename and the DOI as arguments.
(straight-use-package
'(pdf-drop-mode :type git :host github :repo "rougier/pdf-drop-mode"))
(require 'pdf-drop-mode)
(defun my/pdf-process (file doi)
(message "%s : %s" file doi))
(setq pdf-drop-search-hook #'my/pdf-process)
(pdf-drop-mode)
You can then drag and drop a PDF onto the buffer and the DOI should be displayed.