two-column pdf: cannot select a single column
Describe the bug In some two-column pdfs, selection extends over the two columns. In other words, we cannot select a single column.
Steps to Reproduce the behaviour Steps to reproduce the behaviour:
- Open the provided file (providing two pages, as an example; the full reference is from here: https://onlinelibrary.wiley.com/doi/full/10.1111/jeb.14202 "Environmental variance in male mating success modulates the positive versus negative impacts of sexual selection on genetic load" by Tschol, Reid, Bocedi, 2023, J. Evol. Biol)
- In the first page provided, try to select text to highlight
- Both columns are selected.
What is the expected behaviour? That we can select text in either one of the columns, not extending over both columns. (For example, with Okular I can properly select just the text of the column I want).
Desktop Please complete the following information:
- OS: Debian GNU Linux
- Emacs Version: GNU Emacs 29.0.92 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.37, cairo version 1.16.0) of 2023-07-06
- Poppler Version: libpoppler-dev: 22.12.0-2+b1
Your pdf-tools install Please complete the following information:
pdf-toolsVersion: Status: Installed in ‘pdf-tools-20230611.239/’ (unsigned). Delete Version: 20230611.239 Commit: c69e7656a4678fe25afbd29f3503dd19ee7f9896pdf-toolscustomization / configuration that you use
(use-package pdf-tools
:ensure t
:commands (pdf-sync-forward-search
try-pdf-outline-on-left
pdf-view-current-page
pdf-outline-on-left
)
:init
(pdf-loader-install)
:mode (("\\.pdf\\'" . pdf-view-mode))
:hook (TeX-after-compilation-finished . TeX-revert-document-buffer)
:config
(progn
(setq-default pdf-view-display-size 'fit-page) ; fit page by default
(setq pdf-annot-default-text-annotation-properties
(quote
((icon . "Note")
(color . "#ff0000")
(label . "X") ;; for reviews
(popup-is-open))))
(add-hook 'pdf-annot-list-mode-hook
(lambda ()
(pdf-annot-list-follow-minor-mode)) ;; C-c C-f for enabling/disabling
)
(bind-key "M-w" 'pdf-view-kill-ring-save pdf-view-mode-map)
(define-key pdf-view-mode-map (kbd "h")
'pdf-annot-add-highlight-markup-annotation)
(define-key pdf-view-mode-map (kbd "t")
'pdf-annot-add-text-annotation)
(define-key pdf-view-mode-map (kbd "D")
'pdf-annot-delete)
(add-hook 'pdf-view-mode-hook
(lambda()
(setq-local split-width-threshold 1)
)
)
(defun pdf-outline-on-left ()
"Split pdf into two windows, display outline on left, 1/3 of original size"
(interactive)
(let ((hlineso (window-total-width)))
(split-window-horizontally (round (* 0.33 hlineso)))
(display-buffer-same-window (pdf-outline-noselect) nil)
)
)
;; do not fail
(defun try-pdf-outline-on-left ()
(interactive)
(condition-case nil
(pdf-outline-on-left)
(error nil)
)
)
(define-key pdf-view-mode-map (kbd "O")
'pdf-outline-on-left)
)
)
Additional context
-
If you are reporting a bug, please try and attach an example PDF file where I can reproduce the bug. Attached. ex1.pdf
-
If you can attach screenshots or recordings, that is a great help: attached
-
Please try reproducing the bug yourself on Vanilla Emacs before reporting the problem. Done with
emacs -Qand then
(require 'package)
(package-initialize)
(use-package pdf-tools)
(pdf-loader-install)
The screenshot is precisely with this minimal configuration.
Just adding this comment, to bump this issue: I continue experiencing these problems, in PDFs that are annotated just fine with Okular.
Current settings:
- pdf-tools:
pdf-tools-20240429.407 - Emacs 30.0.93 (with both gtk and lucid:
GNU Emacs 30.0.93 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.43, cairo version 1.18.2) of 2024-12-23andGNU Emacs 30.0.93 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.18.2, Xaw scroll bars) of 2024-12-26) - OS: Debian GNU Linux
- poppler: lipoppler-dev:
libpoppler-dev:amd64 24.08.0-2
Just adding this comment, to bump this issue: I continue experiencing these problems, in PDFs that are annotated just fine with Okular.
Current settings:
* pdf-tools: `pdf-tools-20240429.407` * Emacs 30.0.93 (with both gtk and lucid: `GNU Emacs 30.0.93 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.43, cairo version 1.18.2) of 2024-12-23` and `GNU Emacs 30.0.93 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.18.2, Xaw scroll bars) of 2024-12-26`) * OS: Debian GNU Linux * poppler: lipoppler-dev: `libpoppler-dev:amd64 24.08.0-2 `
Can you try evince? It uses the same poppler backend as us and if it suffers from the same problem it is probably a poppler-glib bug.
Yes, both evince and atril (a fork of evince) present this same problem.
For the sake of checking what Okular (that does not show the problem) and evince are using here, this is the output of pmap; so the culprit would be libpoppler-glib ?
pmap $(pidof okular) | grep poppler
844K r---- libpoppler.so.140.0.0
1744K r-x-- libpoppler.so.140.0.0
768K r---- libpoppler.so.140.0.0
360K r---- libpoppler.so.140.0.0
24K rw--- libpoppler.so.140.0.0
188K r---- libpoppler-qt5.so.1.36.0
272K r-x-- libpoppler-qt5.so.1.36.0
80K r---- libpoppler-qt5.so.1.36.0
20K r---- libpoppler-qt5.so.1.36.0
4K rw--- libpoppler-qt5.so.1.36.0
112K r---- okularGenerator_poppler.so
136K r-x-- okularGenerator_poppler.so
36K r---- okularGenerator_poppler.so
16K r---- okularGenerator_poppler.so
4K rw--- okularGenerator_poppler.so
pmap $(pidof evince) | grep poppler
844K r---- libpoppler.so.140.0.0
1744K r-x-- libpoppler.so.140.0.0
768K r---- libpoppler.so.140.0.0
360K r---- libpoppler.so.140.0.0
24K rw--- libpoppler.so.140.0.0
124K r---- libpoppler-glib.so.8.26.0
224K r-x-- libpoppler-glib.so.8.26.0
104K r---- libpoppler-glib.so.8.26.0
24K r---- libpoppler-glib.so.8.26.0
4K rw--- libpoppler-glib.so.8.26.0
Searching for reports of this problem, I've found https://bugs.launchpad.net/ubuntu/+source/poppler/+bug/594205 (also https://gitlab.freedesktop.org/poppler/poppler/-/issues/409) . In the first link it seems to be marked as solved as the problem would be due to misordered columns. Yet, the file "Example.pdf", mentioned in that bug report, is problematic for Evince but not for Okular. (I haven't been able to locate the two other files mentioned in this thread: global.pdf and bookreview.pdf).
And in https://bugs.launchpad.net/ubuntu/+source/poppler/+bug/33288 file HE-News-Winter-2009.pdf is again problematic for Evince but not Okular.
My understanding, then, is that this is a known issue. So maybe we can close this?
Yes, both evince and atril (a fork of evince) present this same problem.
For the sake of checking what Okular (that does not show the problem) and evince are using here, this is the output of
pmap; so the culprit would belibpoppler-glib?
Yes, as far as I understand, poppler has a bunch of higher-level libraries that integrate with different toolkits. okular uses the qt frontend which is better maintained at the moment than the glib one which pdf-tools and evince use.
Closing the bug is up to you but leaving it open might be better for other people who might bump into this issue.
Understood, thank you. I'll leave it open then, but of course feel free to close if deemed a better option.