pwmt / zathura

Document viewer
https://pwmt.org/projects/zathura
zlib License
2.03k stars 141 forks source link

[Feature Request] Annotations #51

Open sebastinas opened 6 years ago

sebastinas commented 6 years ago

On GitLab by @GBlanco on Mar 11, 2018, 22:24


Hello Zathura Team!

First of all, thank you very much for this great product you tailor! It is by far my most preferred pdf viewer (also a vim lover), I've been using it for years now.

The only feature I miss in zathura is the possibility of creating annotations, it really breaks the workflow to switch from one viewer to another just to annotate something and come back to zathura. I could read everything on any other pdf viewer, but they all fail not being like zathura... :(.

Before filling this issue I've carefully looked at the code of both mupdf and poppler plugins in the hope of finding a suitable way of adding this feature and implement it myself. In the end I recognized it should be added at the core level, so I went straight to the zathura code and saw a feature/annotations branch, but also, that is really out of my possibilities to implement it myself.

Best regards, Guillermo.

sebastinas commented 6 years ago

On GitLab by @plalloni on Mar 31, 2018, 17:29


@GBlanco what other viewer are you using for doing annotations?

sebastinas commented 6 years ago

On GitLab by @GBlanco on Jun 16, 2018, 18:42


Hi @plalloni,

Sorry for the delay, I didn't received a notification.

The other viewer I'm using is Okular :)

sebastinas commented 6 years ago

On GitLab by @sanjay_ankur on Jul 2, 2018, 13:38


Somewhat unrelated question: how does one read annotations in Zathura (can one?)? I see that an icon is displayed, but I cannot figure out how to access them (not even clicking with the mouse works).

sebastinas commented 6 years ago

On GitLab by @GBlanco on Jul 16, 2018, 13:49


Hi,

It is not supported by now.

@all I finally took the feature-annotations branch and updated it with all the new code. I branched off from develop at tag 0.4.0, although I don't know if I should have done it from the latest develop commit.

The project compiles perfectly and works well, however more work is needed and there are a few design decisions to be made, for example whether to write the messages inside a new popup or on the command bar at the bottom.

To keep a record, I did this on a fork of the project. I'll continue with it this summer and maybe a pull request could be submitted.

sebastinas commented 5 years ago

On GitLab by @ojzim on Nov 18, 2018, 07:19


I have a suggestion. Take a look at qpdfview. in qpdfview, you can highlight every place on the document using Control+Mouse click+Dragging, even if there is no text. But in Okular, you can highlight only where text exists.

The difference is in scanned documents. in qpdfview, you can highlight texts in scanned documents, but in okular you can't.

sebastinas commented 5 years ago

On GitLab by @guygma on Dec 2, 2018, 20:27


This is also the single feature that keeps me from using zathura as my only PDF reader. I would be happy to contribute to the effort of implementing this feature. With simple annotations and potentially form support, zathura would be feature-complete in my view.

sebastinas commented 5 years ago

On GitLab by @dschrempf on Apr 2, 2019, 15:56


I also want to express that of all enhancements, this one I miss the most. I decided to leave a comment here, because what I am doing at the moment might be interesting for others too. I use Zathura by default. And whenever I have to annotate something, I open Okular from within Zathura with the following key binding:

map <C-a> feedkeys ":exec okular %<Return>"

There might be an easier way than using feedkeys (I tried to use exec, but then the % sign does not work as expected).

One might want to extend this keybinding with scrolling to the page viewed at the moment in Okular, but I did not know how to achieve this.

sebastinas commented 4 years ago

On GitLab by @jcguu95 on Oct 28, 2019, 22:09


In theory I would imagine that to make annotation works one only needs zathura to:

  1. remember an associating file that contains annotation *2. return the current page, location, and location-of-cursor when called
  2. spawn our favorite $EDITOR when called, open the associating file, and scroll to the section that associates to the current page, location, and location-of-cursor.
  3. add layers to the file being read and display the content we want it to show

If we just forget about displaying fancy extra layer in our file being read and just want to take quick notes, all we need, I'd imagine, is to ask zathura to return the current page, location, and location-of-cursor.. and then a simple user script should take care of it. The idea is to make zathura more interactive, ask it to feedback more kinds of its current states, and let the user script take care of the rest.


zathura is an amazing project. Though I cannot parse C, I would like to try to contribute (and learn C on the way). Would anyone mind pointing out which file I should pay attention to narrow down?

sebastinas commented 4 years ago

On GitLab by @xxzozaxx on Oct 31, 2019, 19:41


Hey @jcguu95,

I'm happy that someone here is trying to make this feature possible. I'm too interested in implement annotation (but only highlighter) and I skimmed Evince (GNOME pdf reader) code to see how they make it, and here is the conclusion.

basically the all main function you need exist in PopplerAnnot, and I have a little theory about the implementation, you gonna write a handler in zathura, and a simple function in zathura-poppler-plugin. I have a little knowledge about C too, and I read Evince code 2 days ago and still want to explore it more in depth, and didn't read any Zathrua code.

sebastinas commented 4 years ago

On GitLab by @Galicarnax on May 6, 2020, 10:45


Another zathura user here, craving for a (simple) annotation feature. I know that MuPDF currently supports annotations - does this imply that implementing annotations in zathura might be easier with mupdf plugin?

sebastinas commented 4 years ago

On GitLab by @GBlanco on May 6, 2020, 11:14


Hi @Galicarnax, I think it should be more or less easy to implement, as some libraries already support it (MuPDF, poppler...). Inspecting the code, I have a similar feeling to that of @xxzozaxx: A handler in zathura that calls the necessary functions on the pdf libraries. Nevertheless, I think some logic is to be made inside zathura-core, like calculating rect bounds, handle clicks and so on.

Also, I envision some decisions that should be taken care of beforehand. For example, how should the text be inputted to the annotation, how to choose annotation type, shortcuts, etc.

@sebastinas, what do you think? Maybe we can help somehow?

sebastinas commented 4 years ago

On GitLab by @mlq on May 6, 2020, 12:23


We have started implementing annotation support with libzathura, with the necessary types from the PDF standard. In addition, we started adding them to the plugins for mupdf and poppler in their own feature branch:

However, neither poppler (at least not on the glib side) nor mupdf parse all types (and all fields), so for some we started doing that manually (which is fine to do with mupdf).

For the interface, we started implementing new GTK widgets in libzathura-gtk that also gets rid of several other nasty bugs in the current widgets but still does not support all features we have now (but brings back other features as well). In libzathura-gtk, we also started implementing support for all annotation types: https://git.pwmt.org/pwmt/libzathura-gtk/-/tree/develop/libzathura-gtk%2Fpage%2Fannotations

Our plan is to migrate zathura to use libzathura-gtk as soon as at least the feature base of our current zathura version is supported and, thus, also support form fields (most of it is implemented already) and annotations as well.

We appreciate help on all those fronts :smiley:

sebastinas commented 4 years ago

On GitLab by @wisperwind on May 12, 2020, 19:01


This sounds great! I think this is really the feature missing from zathura.

@mlq said:

Our plan is to migrate zathura to use libzathura-gtk as soon as at least the feature base of our current zathura version is supported and, thus, also support form fields (most of it is implemented already) and annotations as well.

We appreciate help on all those fronts :smiley:

Maybe you could open another issue with a rough todo-list? That might be useful for others to figure out where they might help. In fact, I'd interested in helping out with the GTK bits since I've recently been learning to use the glib/gtk ecosystem a bit and this would be a nice project to continue :)

@GBlanco said:

Also, I envision some decisions that should be taken care of beforehand. For example, how should the text be inputted to the annotation, how to choose annotation type, shortcuts, etc.

In my opinion, Okular is actually a good example here: In its review mode (toggled by a keyboard shortcut!), you get a docked toolbar with a number of large buttons to select a few tools. These can be configured in a settings dialog, for zathura that could just go into the config file. Compared to other pdf readers (Evince, Foxit, Preview on macOS), this has immensely better usability: I guess (essentially) everybody uses but a small selection of tools (for me: three highlight colors, sticky note annotations, sometimes wavy underlining), which means each of these can be selected with just one click. In the case of Foxit (which I've been using recently for lack of better alternatives), changing to a highlighter with a different color is easily 3 clicks (select highlight mode, click on color drop-down, click on color) while moving the cursor from one end of the screen to the other. This is a huge distraction while reading.

sebastinas commented 4 years ago

On GitLab by @GBlanco on May 14, 2020, 16:02


@mlq I though the maintainer was Sebastian, my bad :(

@wisperwind said:

Maybe you could open another issue with a rough todo-list? That might be useful for others to figure out where they might help. In fact, I'd interested in helping out with the GTK bits since I've recently been learning to use the glib/gtk ecosystem a bit and this would be a nice project to continue :)

I totally agree, a todo-list could be very helpful, it is a large code base. I have almost no experience with GTK, so maybe I can help on other parts, like the features in mupdf, poppler plugins.

I agree with Okular being a good example, though I feel all those buttons are not the zathura-vim way...

sebastinas commented 4 years ago

On GitLab by @victoriajeegreen on Aug 9, 2020, 19:59


We have started implementing annotation support with libzathura

that's wonderful uwu

However, neither poppler (at least not on the glib side) nor mupdf parse all types (and all fields)

if the challenge proves itself too daunting, may i suggest you guys to take a look into XFDF (a sidecar file that doesn't demand any support on the original file)

>w<

sebastinas commented 4 years ago

On GitLab by @jcguu95 on Aug 26, 2020, 19:29


Thanks for reply! I noticed a super neat way to do annotation.. in plain text! See org-noter for the workflow. The only problem is that org-noter only integrates with pdf-tools.. which crashes my emacs very often. It has long been an issue..

To detach from pdf-tools, it turns out all we need is to communicate and demand zathura to run certain functions externally! That's basically how org-noter works. I have opened up an issue asking how to..

sebastinas commented 4 years ago

On GitLab by @minhaj.sixbyte on Sep 10, 2020, 19:01


cool. thanks for the idea

sebastinas commented 3 years ago

On GitLab by @midhun on Jan 15, 2021, 11:42


This feature would be really great if you implement it on Zathura. Any update on this?

sebastinas commented 3 years ago

On GitLab by @dschrempf on May 30, 2021, 13:08


I was just saying to myself: It is a pain that I have to change my favorite viewer so often to annotate what I am reading :).

sebastinas commented 3 years ago

On GitLab by @Nima on Jul 16, 2021, 04:32


I was just saying to myself: It is a pain that I have to change my favorite viewer so often to annotate what I am reading :).

To relieve the pain, the best work around is map a key to open the page in mupdf and then using mupdf (pressing a in mupdf) for annotation. Since both zathura and mupdf similar in philosophy it is less of a pain than launching Acrobat!

sebastinas commented 3 years ago

On GitLab by @ryan on Sep 8, 2021, 05:13


@dschrempf

Is it possible to add the current page when sending to okular?

I saw Okular has a -p --page number option to open the given page in the document.

I saw a feature request for adding PAGENUMBER for scripts, but not sure if the same applies for mappings.

Would be a game changer on longer documents until Okular's highlighting arrives...

Next I'll have to figure out how to sync highlighting with moon+ reader.

sebastinas commented 3 years ago

On GitLab by @dschrempf on Sep 9, 2021, 13:33


@ryan I do not know. I am still using the key without page number.

sebastinas commented 3 years ago

On GitLab by @dschrempf on Sep 9, 2021, 13:33


I saw below that there is a method to open mupdf, maybe that's preferrable?

sebastinas commented 2 years ago

On GitLab by @ghd on Mar 24, 2022, 03:15


Any updates on this?

sebastinas commented 2 years ago

On GitLab by @keith on Mar 24, 2022, 15:19


The onus for this definitely isn't on the Zathura devs (thank you for all the great work you have already done!), but this is definitely one of the features I find myself thinking about often.

sebastinas commented 1 year ago

On GitLab by @oliverlew on Jan 15, 2023, 13:14


Hey, I am wondering, after changes such as !59, would it be easier to implement the text highlighting annotation? That MR can locate the text rectangles of the user's selected texts. That seems one step towards text highlighting annotation. With this, zathura can get coordinates of the selected texts, pass the coordinates of those rectangles to poppler (this) or mupdf API to add highlighting there, right?

Here is my imagined scenario: first, select text like in !59, then, right clicking the selection will pop up a menu with "highlight select text", last, click the menu item and the texts get highlight annotation. Right click the highlight-annotated texts, a menu pops up with "remove highlighting" to remove the annotation.