ahrm / sioyek

Sioyek is a PDF viewer with a focus on textbooks and research papers
https://sioyek.info/
GNU General Public License v3.0
7.15k stars 236 forks source link

_embed_annotations_in_file saves entire page highlighted #879

Open zhizhongpu opened 11 months ago

zhizhongpu commented 11 months ago

I only highlight half of paragraph in soiyek, which works fine. But when I use the _embed_annotations_in_file command, what eventually gets saved in that file is a pdf where the entire page got highlighted. _embed_annotations_in_file saves entire page highlighted image

image

the pdf file i used is here: https://www.aeaweb.org/articles/pdf/doi/10.1257/jep.25.3.129

jinjiaodawang commented 11 months ago

I have the same problem as you, which is reproducible on many PDF files. I found that the problem exists at:

https://github.com/ahrm/sioyek-python-extensions/blob/b2b17e0b78e990b6544e534682ea66e154bf6272/src/sioyek/sioyek.py#L843-L850

I found some cases when absolute begin is after the absolute end, causing this part of the code to select the entire page for highlighting.

You can open prefs_user.config, typically where you configed sioyek_python_extensions, and change embedding command to:

new_command _embed_annotations python3 -m sioyek.embed_annotations "%{sioyek_path}" "%{local_database}" "%{shared_database}" "%{file_path}" "fitz"

Then everything works fine, tested from my end.