0

I am unable to add text annotations to PDF files when using PDF-Tools. I can place the text annotation icon within the PDF document, but when I click on it to add text annotations a buffer opens up immediately below the open PDF file, were I see a mirror copy of the open PDF file! From what I have seen on YouTube when the text annotation feature is activated, the buffer that opens is where one can add the text annotation. But in my case the PDF file is mirrored in the text annotation buffer instead. Pleas see the screenshot provided. Also I see the error message in the bottom buffer saying: 'Wrong number of arguments: (3 . 4), 5' I presume that this is a configuration problem. Grateful for any help in solving this. enter image description here

My configuration looks like this:

(use-package pdf-tools
  :config
  (pdf-tools-install)
  (setq-default pdf-view-display-size 'fit-width))

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

;;Refresh the buffer after successful latex compile
(add-hook 'TeX-after-compilation-finished-functions #'TeX-revert-document-buffer)

I ran a 'Backtrace' and I got the following output:

Debugger entered--Lisp error: (wrong-number-of-arguments (3 . 4) 5)
  window--display-buffer(#<buffer *Edit Annotation ITT E-BOOK_231010_131005.pdf*> #<window 257 on ITT E-BOOK_231010_131005.pdf> window ((inhibit-same-window . t) (window-height . 0.25)) nil)
  display-buffer-split-below-and-attach(#<buffer *Edit Annotation ITT E-BOOK_231010_131005.pdf*> ((inhibit-same-window . t) (window-height . 0.25)))
  display-buffer(#<buffer *Edit Annotation ITT E-BOOK_231010_131005.pdf*> ((display-buffer-reuse-window display-buffer-split-below-and-attach) (inhibit-same-window . t) (window-height . 0.25)))
  pdf-annot-edit-contents(((buffer . #<buffer ITT E-BOOK_231010_131005.pdf>) (page . 1) (edges 0.52226 0.314815 0.561476 0.345118) (type . text) (id . annot-1-1) (flags . 24) (color . "#ff0000") (contents . "") (modified 26054 45843) (label . "John Doe") (subject) (opacity . 1.0) (popup-edges) (popup-is-open) (created) (icon . "Note") (state . "unknown") (is-open)))
  pdf-annot-default-activate-handler(((buffer . #<buffer ITT E-BOOK_231010_131005.pdf>) (page . 1) (edges 0.52226 0.314815 0.561476 0.345118) (type . text) (id . annot-1-1) (flags . 24) (color . "#ff0000") (contents . "") (modified 26054 45843) (label . "John Doe") (subject) (opacity . 1.0) (popup-edges) (popup-is-open) (created) (icon . "Note") (state . "unknown") (is-open)))
  pdf-annot-activate-annotation(((buffer . #<buffer ITT E-BOOK_231010_131005.pdf>) (page . 1) (edges 0.52226 0.314815 0.561476 0.345118) (type . text) (id . annot-1-1) (flags . 24) (color . "#ff0000") (contents . "") (modified 26054 45843) (label . "John Doe") (subject) (opacity . 1.0) (popup-edges) (popup-is-open) (created) (icon . "Note") (state . "unknown") (is-open)))
  #f(compiled-function () (interactive nil) #<bytecode 0x128f059>)()
  funcall-interactively(#f(compiled-function () (interactive nil) #<bytecode 0x128f059>))
  call-interactively(#f(compiled-function () (interactive nil) #<bytecode 0x128f059>) nil nil)
  command-execute(#f(compiled-function () (interactive nil) #<bytecode 0x128f059>))
8
  • This information needs to be in the question: see my edit to your question and please check that it is identical to what you have. See emacs.stackexchange.com/help/formatting and links therein for help in formatting your posts. In particular, what I used above is called a fenced code block in Markdown parlance: three backticks (that's the fence) before and after the code block.
    – NickD
    Feb 8 at 12:25
  • To diagnose the error, we need a backtrace: do M-x toggle-debug-on-error and then repeat the command that gave you the error. This time, you should get a *Backtrace* buffer pop up: edit your question and copy-and-paste the backtrace into it (use a fenced code block as explained in my first comment - or look at the edit I made to your question as an example of what to do).
    – NickD
    Feb 8 at 16:29
  • @NickD I have added the backtrace to my post. I hope that reveals enough information to fix the problem. Thanks.
    – lloowen
    Feb 10 at 0:05
  • It reveals some information but the problem is likely to be a bug in the function display-buffer-split-below-and-attach which is found in pdf-utils.el which is part of pdf-tools. I suspect that the final nil argument to window--display-buffer is erroneous and is somehow passed from display-buffer-split-below-and-attach, but I don't see it in my version (pdf-tools-20230611.239): what version of pdf-tools are you using? You might try an upgrade, but no guarantees.
    – NickD
    Feb 10 at 13:50
  • 1
    Great! Upgrading is (almost) always a good idea when mysterious bugs crop up.
    – NickD
    Feb 11 at 0:39

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.