Closed DrWaleedAYousef closed 7 years ago
The default way that org-ref opens a pdf is if it is named by the bibtex-key in a directory in the variable org-ref-pdf-directory. You can change this by modifying the org-ref-open-pdf-function, and or org-ref-get-pdf-filename-function, in particular see the doc string for the last variable. You may want to use org-ref-get-mendeley-filename for it.
Thanks so much; I tried but it did not work for either single or multiple pdfs. For example, a simple bib and my .emacs are as follows; however when I open the bib and choose org-ref-bibtex-hydra/body then p:Open pdf it does not work. What should I do to the .emacs more than this?
@article{waleed2017thisistitle, author = {Waleed}, title = {This Is the Title}, journal = {PAMI, IEEE}, volume = 17, year = 2017, language = {CAD Mammography} file = {:/home/wyousef/texmf/bibtex/bib/base/b.pdf:PDF;:/home/wyousef/texmf/bibtex/bib/base/a.pdf:PDF} }
(setq reftex-default-bibliography '("/home/wyousef/texmf/bibtex/bib/base/testpublications.bib" "/home/wyousef/texmf/bibtex/bib/base/testbooksIhave.bib"))
(setq org-ref-default-bibliography '("/home/wyousef/texmf/bibtex/bib/base/testpublications.bib") org-ref-pdf-directory "/home/wyousef/texmf/bibtex/bib/base/" org-ref-open-pdf-function '(org-ref-get-mendeley-filename) )
@DrWaleedAYousef I don't use Mendeley, so I can't test it, but see if the function below works for you. If org-ref-get-mendeley-filename
does what is says (return the pdf filename in the file field), it should work.
(defun org-ref-open-bibtex-pdf ()
(interactive)
(save-excursion
(bibtex-beginning-of-entry)
(let* ((bibtex-expand-strings t)
(entry (bibtex-parse-entry t))
(key (reftex-get-bib-field "=key=" entry))
(pdf (org-ref-get-mendeley-filename key)))
(message "%s" pdf)
(if (file-exists-p pdf)
(org-open-link-from-string (format "[[file:%s]]" pdf))
(ding)))))
Also, I think your definition is not correct, try (setq org-ref-open-pdf-function 'org-ref-get-mendeley-filename)
instead.
My bib library is exported from Mendely; org-ref does not open the pdf. However, helm-bibtex does! it gives me the following error message: Wrong type argument: stringp, nil