ahrm / sioyek

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

Support DJVU and EPUB #5

Open Bamajon1974 opened 3 years ago

Bamajon1974 commented 3 years ago

Many STEM related ebooks are in DJVU format and I highly recommend adding support. And if you are going to the trouble to adding DJVU support, might as well add ebook as well.

ahrm commented 3 years ago

Actually we support epub right now (becasue MuPDF supports epub), though there is not reflowing. Adding DJVU support would require a significant refactor (which is healthy for the codebase anyway) because currently MuPDF is hardcoded in many places.

Because of the significant amount of refactor required, adding DJVU support is not in my immediate roadmap, but it is definitely something that I will do at some point.

Bamajon1974 commented 3 years ago

Thank you!

pedrolimasi commented 2 years ago

Hey @ahrm, would you drop some bullet-points/tasks here for the refactor? This seems to be a highly requested feature, so it would be good to start drafting a roadmap for djvu support. Others, like myself, may want to contribute some weekend time for a pull-request.

ahrm commented 2 years ago

You would have to create a generic type for all mupdf types (e.g. fz_document, fz_pixmap, etc.) and create a wrapper around mupdf and libdjvu which both return these generic types. A quick grep shows that there are about 500 instances where we have used mupdf types in sioyek source code. Before you dedicate any time to this, I must warn you that I will accept a pull request only if:

  1. It doesn't break existing functionality
  2. It doesn't make the code too complicated
  3. It provides a working djvu functionality (I won't accept incremental steps in the main branch, you can create a djvu branch for such changes)

Honsetly, I would say that it is not worth it (unless you are doing it for fun). Because converting djvu to pdf is trivial, and since our target audience is more technically inclined than normal PDF viewers, I would say most of them know how to convert these formats.

And probably the best place to do it is in mupdf rather than sioyek. I don't know if mupdf people are interested in supporting djvu or not (they do already support other formats like epub and cbz, so I would assume they would be open to supporting djvu). But if you could add djvu support to mupdf it could benefit a lot more people.