Giter Club home page Giter Club logo

org-pdftools's Introduction

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

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

Installation

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

https://melpa.org/packages/org-pdftools-badge.svg

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.

(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)))

Latest release note

Usage

In order to link a specific page of a .pdf-file in an org-file, use the following syntax:

[[pdf:~/file.pdf::3][Link to page 3]]

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:

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

Current features

The provided function includes:

  • [X] (Sort-of) backward compatibility with org-pdfview: simply change the link prefix from pdfview: to pdf:.
  • [X] The reason this URL prefix change was proposed is that pdftools: links can also point to pdf-occur searchs. Multi-file search is also supported.
  • [X] There is also support for pdf-isearch.
  • [X] Beyond the original link implementation that stores only file path and page number, now you can store the precise location of annotations.
  • [X] If there are selected texts on the current PDF page, it will be marked-up using pdf-tools markup functions (by default, underline) automatically and the corresponding annotation id is stored in the link.
  • HTML exported link now have a “#page=n” postfix, which should make browsers like Chrome open the corresponding page.
  • You can now customize the link description format using org-pdftools-get-desc-function
  • Added org-noter-pdftools-embed-org-note-to-pdf, org-noter-pdftools-embed-all-org-note-to-pdf to copy one or all org-noter annotation headings (the ones with a annot-id and org-pdftools link) to the corresponding PDF file.
  • Added org-noter-pdftools-embed-org-buffer-to-pdf to copy the whole org-noter buffer to a annotation in the left upper corner of the first page in the PDF.
  • Added org-noter-pdftools-jump-to-note config in the README.
  • The prefix of pdftools link can now be customized using org-pdftools-link-prefix, and the default is now set to “pdf”
  • The org-pdftools-search-string-separator is now set to ?? to avoid org fontification problem
  • You can now specify how the path of pdf is stored using two function:
  • org-pdftools-path-generator takes buffer-file-name as an argument, and output a translated path. Default to abbreviate-file-name
  • org-pdftools-path-resolver takes a translated path as an argument and translate it back to absolute path. Default to expand-file-name

Integration with org-noter

You can use the vanilla org-noter now.

  • [X] Integrate with org-noter, such that org-noter can remember the precise location (in the resolution of the exact annotation).
  • [X] Jump from a PDF annotation to a associated org-heading org-noter-sync-* and org-noter-jump-to-heading.
  • [X] Transform old org-noter notes to newer ones and sync with the corresponding PDF. org-noter-convert-old-notes
  • [-] PDF annotation will have full and synced information with the associated org-note. (Besides the note content, each annotate will record the IDs of the corresponding org heading and potentially even it’s parent org heading, such that tree-rebuild is possible.)

Planed features

This is the first step of a set of overhauls of Emacs PDF notetaking experience. The features below are planned (either in this package or as PR to other packages):

  • [-] Optionally grab image/text excerpt from the PDF and insert below the corresponding org-heading. Please refer to pdf-view-extract-region-image, not sure what’s the best way to integrate it.
  • [ ] Link export with image/text-based excerpt from the PDF.
  • [ ] (Long-term) Org <-> PDF Annotation converter.

org-pdftools's People

Contributors

charlie-gordon avatar cpbotha avatar dalanicolai avatar fbanados avatar fuxialexander avatar jgru avatar jwiegley avatar lemonbreezes avatar lytex avatar mohkale avatar rdiaz02 avatar smallzhan avatar stardiviner avatar torfjelde avatar xzz53 avatar zhengqunkoo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

org-pdftools's Issues

Can not create skeleton

Hi,
I have installed the package (through use-package from Melpa) and configure as it written in the instructions. Then, from a pdf file try to create a skeleton of the annotations in such file, but get from org-noter-pdftools-create-skeleton:

helm-M-x-execute-command: Symbol’s value as variable is void: org-noter-pdftool-link-generator

or from org-noter-create-skeleton

helm-M-x-execute-command: Wrong type argument: org-noter-pdftools--location, nil

although, this time, the highlighted annotations are created. Note also if I comment out the org-pdftools lines, then org-noter-create-skeleton works.

Thanks in advance for your help,

Arcesio Castaneda

relative pdf links

It would be cool if links to pdfs were relative to the current file instead of absolute. Such as when you've a got README.org file for a project and a bunch of pdfs in subdirectories within the project. It'd make things a lot more portable (I believe).

Ideally we'd tell org-pdftools to insert relative links by setting a buffer local variable in the org file. something like:

# -*- org-pdftools-link-style: relative -*-

* Foo

and then make sure if when someone runs org-insert-link on a file in the same or a subdirectory of the current-directory, then that link is inserted relatively.

config typo in readme

(use-package org-noter-pdftools
  :after org-noter
  :config
  (with-eval-after-load 'pdf-annot
    (add-hook pdf-annot-activate-handler-functions #'org-noter-pdftools-jump-to-note)))

the 5th line should be

    (add-hook 'pdf-annot-activate-handler-functions #'org-noter-pdftools-jump-to-note)))

need a quote to pdf-annot-activate-handler-functions

org-store-links breaks on "Wrong number of arguments"

org-link-store-props: Wrong number of arguments: (lambda (from-org-noter) "Get link from the active pdf buffer." (let* ((path (concat org-pdftools-root-dir (file-relative-name buffer-file-name org-pdftools-root-dir))) (page (image-mode-window-get 'page nil)) (annot-id (if (pdf-view-active-region-p) (pdf-annot-get-id (funcall org-pdftools-markup-pointer-function (pdf-view-active-region t) org-pdftools-markup-pointer-color (list (cons 'opacity org-pdftools-markup-pointer-opacity)))) (if (and (not from-org-noter) (pdf-annot-getannots page)) (condition-case nil (pdf-annot-get-id (pdf-annot-read-annotation "Click the annotation that you want to link to.")) ((debug error) (message "error"))) (if (y-or-n-p "Do you want to create a free pointer annotation for the link?") (pdf-annot-get-id (funcall-interactively #'pdf-annot-add-text-annotation (pdf-util-read-image-position "Click where a new text annotation should be added ...") org-pdftools-free-pointer-icon (list ... ...))) nil)))) (height (cond ((and (boundp 'annot-id) annot-id) (nth 1 (pdf-annot-get (pdf-info-getannot annot-id path) 'edges))) (t (/ (* (or (image-mode-window-get ...) 0) (frame-char-height)) (float (cdr (pdf-view-image-size))))))) (link (concat "pdftools:" path "::" (number-to-string page) "++" (format "%.2f" height) (if annot-id (concat ";;" (symbol-name annot-id)) nil)))) link)), 0

org-pdftools version: d19ba88
Emacs version: GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.5) of 2019-08-07

Backtrace:

Debugger entered--Lisp error: (wrong-number-of-arguments (lambda (from-org-noter) "Get link from the active pdf buffer." (let* ((path (concat org-pdftools-root-dir (file-relative-name buffer-file-name org-pdftools-root-dir))) (page (image-mode-window-get 'page nil)) (annot-id (if (pdf-view-active-region-p) (pdf-annot-get-id (funcall org-pdftools-markup-pointer-function ... org-pdftools-markup-pointer-color ...)) (if (and ... ...) (condition-case nil ... ...) (if ... ... nil)))) (height (cond ((and ... annot-id) (nth 1 ...)) (t (/ ... ...)))) (link (concat "pdftools:" path "::" (number-to-string page) "++" (format "%.2f" height) (if annot-id (concat ";;" ...) nil)))) link)) 0)
  org-pdftools-get-link()
  (org-link-store-props :type "pdftools" :link (org-pdftools-get-link) :description desc)
  (let ((desc (if (pdf-view-active-region-p) (replace-regexp-in-string "\n" " " (mapconcat 'identity (pdf-view-active-region-text) 32))))) (org-link-store-props :type "pdftools" :link (org-pdftools-get-link) :description desc))
  (cond ((eq major-mode 'pdf-view-mode) (let ((desc (if (pdf-view-active-region-p) (replace-regexp-in-string "\n" " " (mapconcat ... ... 32))))) (org-link-store-props :type "pdftools" :link (org-pdftools-get-link) :description desc))) ((eq major-mode 'pdf-occur-buffer-mode) (let* ((paths (mapconcat #'identity (mapcar #'car pdf-occur-search-documents) "%&%")) (search-string pdf-occur-search-string) (link (concat "pdftools:" paths "@@" search-string))) (org-link-store-props :type "pdftools" :link link :description (concat "Search PDF for: " search-string)))))
  org-pdftools-store-link()
  org-store-link(nil 1)
  funcall-interactively(org-store-link nil 1)
  call-interactively(org-store-link nil nil)
  command-execute(org-store-link)

pdf-view buffer unusable after enabling org-noter

Hi. Thanks for taking the time to develop this extension. Love the idea!

I've followed the setup instructions. After I enable org-noter I'm immediately prompted to decide if I want to add a note. When entering 'n' I'm propped again for a search.

Any click or key press, including page up or down re-prompts and I can't use the buffer containing the pdf I've opened.

Open a pdf(view) link of a djvu file (mistakenly) causes severe memory allocation

I just found out an issue comes from org-pdfview inherited by org-pdftools.
If one mistakenly opens a link [[pdf:xxxx.djvu][DJVU file]], it causes severe memory allocation and freezes the PC. Since djvu, ps or pdf are all somehow usual, I think it's better to check in the open function if it really deals with a pdf before trying open it.

It's a bit annoying to accidentally make the mistake and make the PC freeze.

different behavior between insert-note and insert-precise-note?

When using org-noter-pdftools I find no difference between i (org-noter-insert-note) and M-i (org-noter-insert-precise-note).

I find it counterintuitive that org-noter-insert-note asks the question You can click anywhere on the page to add a link to. Do you want to do that? : mimicking the behavior of org-noter's org-insert-note I was expecting that a link to the page, without further questions, be inserted in the org buffer. So I think I am misunderstanding something here.

Help with setting this up

Thanks for this very useful package. I have a question. I am also using pdf-tools with org-ref (+ helm-bibtex). There are many ways to create "notes" for a pdf, using helm-bibtex or with org-ref or with org-noter. But the headers are differently created. Can you explain your workflow and what are the required changes in the doom private configs?

For example, in the documentation, the path to pdfs is set like this (use-package org-pdftools :config (setq org-pdftools-root-dir /path/you/store/pdfs)). But I have pdfs stored in hierarchical sub-directories (by journal and authors). What would be the way to work around this?

bump required org-version

I'm unable to require this package because it depends on org-refile.el which was introduced under a month ago.

Is it an essential require? I removed the require call from the file to load it and everything's working fine on my end so far.

Exporting org with org-pdftools links results in incorrect link to source PDF

I have an org file with notes about some manuscript (PDF) with org-pdflinks. When I export the notes to PDF, there are links in the resulting PDF but their URLs are incorrect. Evince says the link is the local path of the notes followed by the absolute path of the manuscript PDF. Needless to say, these links don't work.

show recentf, alongside new ones for pdf targets?

Is there a recommended way of choosing PDFs, as it stands I've got PDFs put into sub-directories and am quite often only working with one PDF at a time. Whenever I decide to insert a link to that PDF, I have to navigate to the same file which is an error-prone and tasking process.

It'd be nice if, when I decide to insert a PDF link, org-pdftools offers to use my last PDF file or at least shows it as an option alongside the rest of the files in the current directory.

NOTE I'm not using emacs to view the PDFs (so I'm really only using this plugin to create links to PDF slides), so org-store-link isn't really a viable option.

Error when running use-package code

Running (use-package org-pdftools :config (setq org-pdftools-root-dir /path/you/store/pdfs)) throws this error.

Debugger entered--Lisp error: (error "Package ‘org-pdftools-’ is unavailable")
  signal(error ("Package ‘org-pdftools-’ is unavailable"))
  error("Package `%s-%s' is unavailable" org-pdftools "")
  package-compute-transaction(nil ((org-pdftools)))
  package-install(org-pdftools)
  use-package-ensure-elpa(org-pdftools (t) nil)
  (progn (use-package-ensure-elpa (quote org-pdftools) (quote (t)) (quote nil)) (defvar use-package--warning41 (function (lambda (keyword err) (let ((msg (format "%s/%s: %s" ... keyword ...))) (display-warning (quote use-package) msg :error))))) (condition-case err (if (not (require (quote org-pdftools) nil t)) (display-warning (quote use-package) (format "Cannot load %s" (quote org-pdftools)) :error) (condition-case err (progn (setq org-pdftools-root-dir (quote ~/Zotero/storage)) t) ((debug error) (funcall use-package--warning41 :config err)))) ((debug error) (funcall use-package--warning41 :catch err))))
  eval((progn (use-package-ensure-elpa (quote org-pdftools) (quote (t)) (quote nil)) (defvar use-package--warning41 (function (lambda (keyword err) (let ((msg ...)) (display-warning (quote use-package) msg :error))))) (condition-case err (if (not (require (quote org-pdftools) nil t)) (display-warning (quote use-package) (format "Cannot load %s" (quote org-pdftools)) :error) (condition-case err (progn (setq org-pdftools-root-dir (quote ~/Zotero/storage)) t) ((debug error) (funcall use-package--warning41 :config err)))) ((debug error) (funcall use-package--warning41 :catch err)))) nil)
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)

free-text notes are not extracted

"Free-text" notes (what Okular calls "Inline notes" and "Typewriter notes" and Foxit calls "callout", "text box", "typewriter" notes) are not extracted. I suppose this cannot be fixed (pdftools cannot create these annotations; it can edit them, but will not list them. See politza/pdf-tools#438)?

As an example, I am attaching a pdf with an "Inline" and a "Typewriter" note. Both were created with Okular, and then I added more text using pdf-tools: ex-annot.pdf

This non-extraction also affects, of course, similar notes created with, for example, android apps for annotating PDFs.

Both org-noter (https://github.com/weirdNox/org-noter) and org-noter-pdftools (https://github.com/fuxialexander/org-pdftools) are affected.

For the record, these types of notes are not extracted either by Zotfile (http://zotfile.com/) using pdf.js (https://mozilla.github.io/pdf.js/).

pdftools: org link type not recognized + xdg-open is used instead of pdfview

I just installed pdf-tools and org-pdftools and have the following two weird behaviors:

  1. Any links of the form [[./file.pdf]] within a org file gets opened externally using /usr/bin/xdg-open instead of within emacs! (but if I click on a file from within dired, it gets properly opened within emacs with pdfview)

  2. Any links of the form [[pdftools:./file.pdf]] within a org file does not get opened at all. When clinking on the link the following result is shown "No match - create this as a new heading? (y or n)". Then entering "n" appears "No match for fuzzy expression: pdftools:./file.pdf". Does org-pdftools not play well with other packages?

Emacs version: GNU Emacs 27.1

pdftools configuration:

(use-package pdf-tools
:ensure t
:config
(pdf-tools-install)
(setq-default pdf-view-display-size 'fit-width)
(define-key pdf-view-mode-map (kbd "C-s") 'isearch-forward)
(setq pdf-annot-activate-created-annotations nil)
(setq pdf-view-resize-factor 1.1)
(setq TeX-view-program-selection '((output-pdf "PDF Tools"))
TeX-view-program-list '(("PDF Tools" TeX-pdf-tools-sync-view))
TeX-source-correlate-start-server t)
(add-hook 'TeX-after-compilation-finished-functions
#'TeX-revert-document-buffer)
)

org-pdftools configuration:

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

(use-package org-noter-pdftools
:ensure t
:after org-noter
:config
(with-eval-after-load 'pdf-annot
(add-hook 'pdf-annot-activate-handler-functions #'org-noter-pdftools-jump-to-note)))

Any help to fix the two issues would be greatly appreciated, thank you.

Is org-pdftools supposed to be a replacement for org-pdfview?

Hi,

Thanks for org-pdftools. I wish it could act as a replacement for org-pdfview.
When I export some org subtree to latex, then I compile it, I was used
to org-pdfview opening the resulting PDF.
It is not the case with org-pdftools.

With org-pdfview, I am able to open a PDF file like this:
(org-open-file "~/pdf/TD3-BN.pdf")
but with org-pdftools, it seems that the path does not match the link,
hence nothing is opened.

I set org-file-apps accordingly in both cases and tried to edebug through org-pdftools-open.

Any insight about the differences and what is expected?

Regards,

Error during configuration

Hi. I installed the latest version of org-pdftools from MELPA and and tried to configure it as follows:

(require 'org-pdftools)
(add-hook org-load-hook 'org-pdftools-setup-link)

But I am getting the following error:

Debugger entered--Lisp error: (setting-constant nil)
  add-hook(nil org-pdftools-setup-link)
  eval((add-hook org-load-hook 'org-pdftools-setup-link) nil)
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)

However there is no error if I perform M-x eval-expression (org-pdftools-setup-link) on an org-mode buffer.

OS: Ubuntu 20.04
GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.20) of 2020-08-28

org-link-set-parameters moved to config?

In the newest version, org-link-set-parameters lines are moved to config files, the function is in ol.el file, so maybe adding (require 'ol) and putting org-link-set-parameters lines in org-pdftools.el is better.

Exporting links to annotations with page and line number (or similar)

I use this package for reviewing manuscripts. When I send my comments to the authors of those manuscripts, the links become useless because they typically don't use Emacs and the links in the exported PDF point to an absolute disk location. Would it be possible to export without links but with automatically added references like "(page 30, line 11)"?

Thanks for this package. Extremely useful for my work!

Issues creating org-noter skeleton from PDF annotations

When I run M-x org-noter-create-skeleton, specifically to export annotations, I get the following error:

org-noter-pdftools--pretty-print-location: Wrong type argument: org-noter-pdftools--location, nil

Any suggestions gratefully received.

pdf: link export description to `nil`

It happens that all my pdf: links are exported to a nil link, i.e. the description is replaced by nil. This can be checked for instance with org-latex-export-as-latex: description are exported as nil in LaTeX. But this issue is present for other export type. It occurs even for pdf: link without description.

I checked the code source, and the function org-pdftools-export looks standard. I put a (message "%s" desc) inside that function, and it always outputs nil. Very weird issue. It's not an Org mode bug, because all other link export description correctly.

emacs version: emacs 28.0.50
org version: 9.4
package version: 20200422.1350

org-noter-insert-precise-note stopped working after installing org-pdftools

Steps for reproduction:

  • Select text in a pdf
  • Call org-noter-insert-precise-note or org-noter-pdftools-insert-precise-note
  • Leave the prompt Note: empty, i.e., just hit return
  • Gets the error let: Wrong type argument: listp, #s(org-noter-pdftools--location...
  • Despite the thrown error, the text in the pdf is highlighted without any trace in the org-file, thus, adding insult to injury :)

Expected behavior:

  • The selected text is highlighted and copied into the notes org-file annotated with links back to the original.

Observations:
The variable location in org-noter.el is a simple cons cell with x and y value. But after installing org-pdftools, location turns into a cl-defstruct with type org-noter-pdftools--location. And this crashes due to the frequent use of (car location) which won't work on a cl-defstruct. The problem persists with org-noter-pdftools-insert-precise-note from the readme.

Please help!

Warnings when installing from MELPA

I receive these messages:

In org-noter-pdftools-create-skeleton:
org-noter-pdftools.el:543:41:Warning: reference to free variable
    `org-noter-pdftool-link-generator'

In org-noter-pdftools-embed-org-note-to-pdf:
org-noter-pdftools.el:640:24:Warning: assignment to free variable `kr'
org-noter-pdftools.el:645:22:Warning: reference to free variable `kr'

org-pdftools-complete-link inserts pdfview link, not pdftools

I've been having some trouble getting this plugin setup. Whenever I run org-insert-link, choose pdftools, insert a link and then try to open it; emacs says file not found. I've finally figured out that it's because the link is being written as:

[[pdfview:COM2004/Week 1/Week1a.handout.pdf::1][welcome]] buddy

but pdftools is registered (and only seems to work with) with the link:

[[pdftools:COM2004/Week 1/Week1a.handout.pdf::1][welcome]] buddy

it's this line in pdftools.el that's causing the issue. I've added the following to my config file to fix it for now.

;; register pdfview as an alias for pdftools.
(if (fboundp 'org-link-set-parameters)
    (funcall 'org-link-set-parameters
             "pdfview"
             (cdr (assoc "pdftools" org-link-parameters)))
  (org-add-link-type
   "pdfview" 'org-pdftools-open))

but this results in both pdftools and pdfview being shown as options in org-insert-link despite being aliases for each other. I'd like an upstream fix for this.

org-load-hook didn't work for me to get the `pdf:` link set up

After this change it worked

(use-package
  org-pdftools
  :after org
  :config (org-pdftools-setup-link))
  ;; :hook (org-load . org-pdftools-setup-link))

I'm not proficient enough in Emacs to know if this is a good solution.

A wild guess is that it might be related to straight.el, but I haven't tried without.

org-refile

GNU Emacs 27.0.50 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.22.11) of 2019-09-28, Org mode version 9.3.6. I was trying to install org-pdftools.el and It failed on line L33 (require 'org-refile). he cant find this package. I commented out this line and then everything went smooth.

`Package org-noter-pdftools is incompatible.

I am on Debian 10 with the latest Emacs and Org-Mode built from Source. M-x org-version:

Org mode version 9.3 (release_9.3 @ /usr/local/share/emacs/28.0.50/lisp/org)

I got the message that Package org-noter-pdftools is incompatible. Is there a workaround for this?

Is there something I can do to give your more information for diagnostics?

`Package org-noter-pdftools is incompatible.

     Status: Incompatible because it depends on uninstallable packages.
    Archive: melpa
    Version: 20200418.929
     Commit: 8cc15bb8014ed1f047eecc0abd8bf447f86c0505
    Summary: Integration between org-pdftools and org-noter
   Requires: emacs-26.1, org-9.4 (not available), pdf-tools-0.8, org-pdftools-1.0, org-noter-1.4.1
   Homepage: https://github.com/fuxialexander/org-pdftools
   Keywords: convenience 
 Maintainer: Alexander Fu Xi <[email protected]>
     Author: Alexander Fu Xi <[email protected]>

Add integration between org-pdftools and org-noter.`

path in id and pdf link

I getting the following after creating a link. The pdf link is correct, not the one in id section.

   :PROPERTIES:
   :NOTER_PAGE: [[pdf:/mnt/2nd_BAY/papers/Janidarmian et al. - 2017 - A comprehensive analysis on wearable acceleration sensors in human activity recognition - Sensors (Switzerla.pdf::5++0.00;;annot-5-31]]
   :ID:       ../../../../mnt/2nd_BAY/papers/Janidarmian et al. - 2017 - A comprehensive analysis on wearable acceleration sensors in human activity recognition - Sensors (Switzerla.pdf-annot-5-31
   :END:

org-pdftools-root-dir not included when creating skeleton

Not sure how to create an issue on your booster branch, but I'm having an issue whereby the resultant links generated by org-noter-create-skeleton aren't including the directory of the PDF in question, thus creating a dud link.

Expected: pdftools:~/Documents/PDF/roberts2013.pdf::3++.....
Observed: pdftools:roberts2013.pdf::3++.....

Here is an excerpt after following the function on my system:

 (defun org-noter-create-skeleton ()
  "Create notes skeleton with the PDF outline or annotations.
Only available with PDF Tools."
  (interactive)
  (org-noter--with-valid-session
   (cond
    ((eq (org-noter--session-doc-mode session) 'pdf-view-mode)
     (let* ((ast (org-noter--parse-root))
            (top-level (org-element-property :level ast))
            (options '(("Outline" . (outline))
                       ("Annotations" . (annots))
                       ("Both" . (outline annots))))
            answer output-data)
       (with-current-buffer (org-noter--session-doc-buffer session)
         (setq answer (assoc (completing-read "What do you want to import? " options nil t) options))

         (when (memq 'outline answer)
           (dolist (item (pdf-info-outline))
             (let ((type  (alist-get 'type item))
                   (page  (alist-get 'page item))
                   (depth (alist-get 'depth item))
                   (title (alist-get 'title item))
                   (top   (alist-get 'top item))
                   pdftools-link path)
               (when (and (eq type 'goto-dest)
                          (> page 0))
                 (when org-noter-use-pdftools-link-location
                   (setq path (file-relative-name
                               (expand-file-name
                                (org-noter--session-property-text
                                 session))
                               org-pdftools-root-dir))
                   (if title
                       (setq pdftools-link
                             (concat
                              "pdftools:"
                              path
                              "::"
                              (number-to-string page)
                              "++"
                              (number-to-string top)
                              "$$"
                              (replace-regexp-in-string
                               " "
                               "%20"
                               title)))
                     (setq pdftools-link
                           (concat
                            "pdftools:"
                            path
                            "::"
                            (number-to-string page)
                            "++"
                            (number-to-string top)))))
                 (push
                  (vector
                   title
                   (if org-noter-use-pdftools-link-location pdftools-link
                     (cons page top))
                   (1+ depth)
                   nil)
                  output-data)))))

I can see org-pdftools-root-dir referenced, and it is defined in my init.el, but I don't have the elisp-foo to troubleshoot this effectively.

Additionally, attempting to follow an org-pdftools link while in an org-noter session throws an error:
org-pdftools-open-pdftools: Invalid function: org-noter--with-valid-session

Storing links using org-store-link works as expected

`org-pdftools-complete-link` produces empty links

I just found out all the links I made yesterday were unusable 😢.

Here's the current body of the function.

(defun org-pdftools-complete-link (&optional arg)
  "Use the existing file name completion for file.
Links to get the file name, then ask the user for the page number
and append it. ARG is passed to `org-link-complete-file'."
  (concat
   (replace-regexp-in-string
    "^file:"
    org-pdftools-link-prefix ":"
    (org-link-complete-file arg))
   "::"
   (read-from-minibuffer
    "Page:"
    "1")))

the org-pdftools-link-prefix ":" part should be outside of the replace regexp in string concatenated together as (concat org-pdftools-link-prefix ":"). as it stands, this always outputs ":::1".

README: org-pdftools hook

In the README configuration

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

The hook has no effect to me (i.e. cannot find a pdf entry in org-link-parameters). Not sure what the documentation means by "when org.el is loaded" since org-mode is byte-compiled. Anyway, I changed the hook to org-mode and the issue is gone.

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

Storing link to page sometimes takes long for large PDFs

I would like to link to specific pages in PDFs that can become quite heavy (> 150mb). I answer both prompts with n and sometimes get the message "reminder: you haven't performed an isearch". Sometimes this message does not appear and I have not been able to reproduce when it happens. Whenever the message appears emacs freezes for a couple of seconds, in other cases it remains responsive and I can directly paste the link into an org file. Why does the message sometimes appear and sometimes not? Can I somehow force consistent behavior?

Incremental reading of PDF's

Incrementally reading PDFs would be a huge boon to many academics using Emacs (of which I believe there are many), and would bring us one step closer to an integrated research environment.

I believe that we can create a workable PDF IR system by mostly stitching together existing tools. In org-noter, we have an extraction mechanism for highlights via its org-noter-create-skeleton function, the relevant section can be found here: https://github.com/weirdNox/org-noter/blob/9ead81d42dd4dd5074782d239b2efddf9b8b7b3d/org-noter.el#L1580

My thinking, which I describe here, is that we have an incremental extraction of highlighted elements, or even more simply an advice-add or function that triggers an extraction via org-noter's code for every highlight made, as its made. Additionally, we can structure the extracted content for org-drill by adding the :drill: tag, making sure the header has a faux subheader so that org-drill recognizes the entry as a card etc.

I use your org-pdftools package, and with org-noter-pdftoolsfacilitating the extracting of a highlight we could have linked entries in ourorg-noterfile back to the highlights position, which can then be drilled viaorg-drill` and whittled down to cleaner entries as described by Supermemo's Piotr Wozniak. I've tested this manually and with a pipeline ending with "clean" cards being eventually sent to Anki, I can attest that it is extremely effective.

My elisp isn't good enough to write such a function, but perhaps someone here could point me in the right direction. I've tried scrutinizing the relevant code in org-noter for clues, but can't really wrap my head around parts of it.

How can I get the marked text in a pdf file?

I have a capture template that stopped working but I don't understand why.

(defun org-capture-pdf-active-region ()
  "Capture the active region of the pdf-view buffer."
  (let* ((pdf-buf-name (plist-get org-capture-plist :original-buffer))
         (pdf-buf (get-buffer pdf-buf-name)))
    (if (buffer-live-p pdf-buf)
        (with-current-buffer pdf-buf
          (car (pdf-view-active-region-text)))
      (user-error "Buffer %S not alive." pdf-buf-name))))

I use the following template:

("pc" "Drill cloze pdf" entry (file+headline "~/Documents/wiki/drill.org" "drills")
                             "** :cloze:drill:\n%(org-capture-pdf-active-region)%?\n%a\n")

This yields the following org entry:

** :cloze:drill:
%![Error: (error The region is not active)]
[[pdf:<path to pdf>:36++0.00;;annot-36-7][<name of pdf>.pdf: Page 36; Quoting: <text from active region>]]

So the link works as expected and the text from the active region is part of the link, but it is not captured by the function org-capture-pdf-active-region which I use in the capture template.

Do you have a suggestion how I could get the highlighted text from the pdf?
If I change the function org-pdftools-get-desc-default like this:

(defun org-pdftools-get-desc-default (file page &optional text)
  (concat "" text)

then the active region is captured but the link doesn't work anymore.

org version this package depends on

I noticed that this package depends on org 9.3.6, which is not even included in emacs-27 branch and can only be installed from elpa.
Are there any features in org 9.3.6 that this package needs but are not found in an older version of org ?

I think it's better if this package can be used with builtin org in emacs 26 at least.

Images, Links, Milestones and small steps towards a full org-pdf converter

Hello there,

This tool is real great! Thank you for maintaining it further.

I actually came here because I wanted a tool to store part of a pdfs as images in an org file. I am realy looking forward to this implementation ! What are the milestones to reach that in your opinion ?

Maybe adding a functionality to store a region instead of just a point would be nice to begin with? For now I use org-download and I do screenshots it looks like this:
Screenshot from 2020-01-28 22-26-00
The problem with this is that I lose the text information. I tried playing around with tesseract but it was not efficient enough. If somehow one could take a screenshot and select the text at point at the same time and then put all this as a link (or multiple links) in the org-file, that would be great!

In my use case, my next step would be to link my headings using org-brain so that I can have generate diagrams and navigate the network. The most beautiful thing would be to also be able to transfer the links inside the pdf to links between org-headers. I guess this goes in the direction of the long term goal you set.

Now I don't so much experience in programming with elisp, but I might be able to help here and there if there is something I can do. I wonder for example why org-pdf-get-link needs to use org-pdftools-root-dir. I don't think I would want to store all my pdf in one place or to duplicate it in this directory each time I want to link it to an org file. Maybe I can fix that if it makes sense ?

Also maybe the interface when storing a link with org-pdftools-store-link is a bit to long and should be divided in smaller functions. For example, if I want to just add a link to a page but no annotations I have to say "no" a lot of time. What do you think ?

I am not sure that the way the links are formatted now are very efficient for a heavy use of the package. I have this

[[pdftools:/pdftools/test.pdf::20++0.00 Reminder: You haven’t performed a isearch!][pdftools:/pdftools/test.pdf::20++0.00 Reminder: You haven’t performed a isearch!]]

which could be reduced to

[[pdftools:/pdftools/test.pdf::20++0.00][pdftools:/pdftools/test.pdf - Page 20]]

or even this

[[pdftools:~/pdftools/test.pdf::20++0.00][test.pdf - Page 20]]

Do you agree ?

I would open a new issue for each specific task if this is relevant.

Cheers,

Théo

insert-note auto-populates with highlighted content, insert-precise-note does not

Firstly, thank you for this package! I have been wanting this mix of highlighting an annotation for my PDF workflow for a while so I'm glad I found it. Secondly, I am pretty new to emacs and programming languages in general so I hope this all makes sense. I anticipate that I have botched something in the configuration.

As the title says, since installing org-pdftools M-x org-noter-insert-note auto-populates the note with highlighted content (as a precise note), while org-noter-insert-precise-note and org-noter-pdftools-insert-precise-note do not. Otherwise, the commands are functionally identical which is also fine. I am running doom emacs, here are the relevant parts of my config.el.

(use-package! org-noter
  :config
  (setq
   ;; The WM can handle splits
   org-noter-notes-window-location 'horizontal-split
   ;; Please stop opening frames
   org-noter-always-create-frame t
   ;; Everything is relative to the main notes file
   org-noter-notes-search-path (list org_notes)
   org-pdftools-use-isearch-link nil
   org-pdftools-use-freestyle-annot nil
   ;; I want to see the whole file
   org-noter-hide-other t
   org-noter-insert-selected-text-inside-note t
   org-noter-kill-frame-at-session-end t
   org-noter-separate-notes-from-heading nil)
  (require 'org-noter-pdftools))
(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-freestyle-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)))

Overall this is a pretty minor issue since the functionality is there. But for some reason in my config org-noter-insert-note is not bound to i and I do not know enough emacs lisp yet to change the keybindings.

Installation from MELPA breaks mu4e package configurations

I have some use-packages for mu4e:

(use-package org-mu4e)
(use-package org-mime)
(use-package mu4e
    ;; mu4e config
    )

Of these, only org-mime is installed from MELPA. Remainder is installed system-wide via Nix.

After a package-install of org-pdftools and adding the below to init.el

(use-package pdf-tools
  :init
  (pdf-tools-install))
;; above use-package for context
(use-package org-pdftools
  :hook (org-mode . org-pdftools-setup-link))

the use-packages for the mu4e packages above break:

Error (use-package): org-mu4e/:catch: Invalid version syntax: ‘’ (must start with a number)
Error (use-package): org-mime/:catch: Invalid version syntax: ‘’ (must start with a number)
Error (use-package): mu4e/:catch: Invalid version syntax: ‘’ (must start with a number)

Removing the org-pdftools configuration and/or removing the package itself does not fix the errors. I have to rm -r ~/.emacs.d/elpa to revert to a previously working state, after first reinstalling my packages.

org-noter-insert-note not working properly

Hey,

I'm setting up the org-noter workflow as mentioned in the description or in the youtube video and I'm having problems with the step of inserting the notes.

When I highlight the text and execute the org-noter-insert-note command Emacs doesn't create a header in the org file as shown in the workflow.
It instead creates a regular annotation and opens its annotation minibuffer. No header is created in the org file and the note counter in the pdf buffer remains 0.

I uploaded a video of it here: https://www.youtube.com/watch?v=0vg-lis08sU

I'm using doom. My dotfiles can be found here: https://github.com/n14s/doomdotfiles

Enabling org-noter-pdftools breaks org-noters compatability with nov.el

I want to annotate both PDFs and EPUBs with org-noter, but it looks like when I enable org-noter-pdftools that annotations made in EPUBs when using nov mode no longer contain the location property.

I haven't had too much of a deep dive into the code of org-noter or org-noter-pdftools, but I suspect it is because the functions org-noter-pdftools uses to override the default functionality of org-noter dont' properly handle when the document buffer is in nov-mode rather than pdf-view-mode.

Please get into melpa so it is easy to install

This looks pretty interesting. Can you get it into melpa or one of the other package repos so that it can be installed easily. Someone mentioned it in a possting somewhere and I came to check it out but was a bit awwwww when I could not install it easily via altering my init.el. =]

lemme know!
ciao!
Daryl

Links relative to attachment directory?

I would like to use paths in pdftools links which are relative to the attachment directory. Is it possible to take into account the attachment directory when resolving pdftools links?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.