SECOND EDIT (incl. 'main' answer)
As mentioned in the comments, this feature has already been implemented into org-pdftools
. However, org-pdftools
does insert a permanent text annotation, but I guess that is not too much of a problem for you.
To get it to work (currently, until https://github.com/fuxialexander/org-pdftools/pull/75 gets merged), just replace the org-pdftools-use-freestyle-annot
with org-pdftools-use-freepointer-annot
in the installation code as given in the org-pdftools README. Afterwards you can insert the pointer/text annotation using M-x org-noter-pdftools-insert-precise-note
. The pointer is customizable also. Just do M-x customize-variable
and type org pointer
to find the relevant variables.
And just to come back to the translation of the y-position, you could translate it as follows, but it is probably not what you desire as it only represents the scrolling position:
(defun my-pointer-function (orig-func &rest args)
(apply orig-func args)
(let ((height (round
(/
(*
(string-to-number (match-string 4 (car args)))
(cdr (pdf-view-image-size)))
(frame-char-height)))))
(pdf-annot-add-text-annotation (cons 10 height) "Circle")))
(THIRD EDIT)
You could delete these pointers again for example when you are changing the page using e.g.:
(defvar my-pointers nil)
(add-hook 'pdf-view-before-change-page-hook #'pdf-pointer-delete-hook-function)
(defun pdf-pointer-delete-hook-function ()
(while my-pointers
(pdf-annot-delete (pop my-pointers))))
I am not sure about the robustness of this code, but you can modify/improve it whenever it seems not to work.
FIRST EDIT
It looks like, if you do not have pdf-tools
installed (i.e. the feature available), then you can use org-pdftools-open-custom-open
to define a custom function for opening the link.
However, this feature appears not to be available when you have pdf-tools installed. So then you could advise the function org-pdftools-open-pdftools
, e.g. as follows:
(defun my-pointer-function (orig-func &rest args)
(apply orig-func args)
(pdf-annot-add-text-annotation '(100 . 200) "Circle")
(print args))
(advice-add 'org-pdftools-open-pdftools :around #'my-pointer-function)
This advice (i.e. the my-pointer-function
) will also print the args. I'll leave it to you to translate the args to some actual position where you would like to have the pointer inserted.
END EDIT
I guess there is no straightforward/default way to achieve this, because it is not possible to draw on .png images in Emacs.
If you still want it, then there are multiple hacks possible, of which probably the easiest option is to draw an icon (text annotation) with pdf-annot-add-text-annotation
, e.g.:
(pdf-annot-add-text-annotation '(100 . 200) "Circle")
.
To preview (or just for fun) the possible icons (in pdf-annot-standard-text-icons
), you can evaluate the following lines in a pdf buffer:
(let ((pos 0))
(dolist (type pdf-annot-standard-text-icons)
(pdf-annot-add-text-annotation (cons pos 0) type)
(setq pos (+ pos 100))))
These annotations will only get saved if you save the document. Or you could additionally add another hack to delete it again when you start scrolling, which should not be too difficult if you know some emacs-lisp.