Toji: a semantic, multi-format document reader for Haiku (PDF, EPUB, comics, DjVu)

Hey everyone,

I’d like to introduce a project I have been working on for Haiku: Toji (綴じ, “binding”: the way a book is bound). Originally called Tsundoku, the project started as a fork of the classic BePDF. Many thanks to its authors, Michael Pfeiffer, Hubert Figuiere, Benoit Triquet, waddlesplash and everyone who contributed over the years.

Soon, Toji had grown into a modern, standards-based reader that uses what Haiku is good at: attributes, queries and messages. It is now at v1.0 beta, and I’d be glad if you would try it and tell me what you think.

Toji reading its own user guide: outline, marks and margin notes

Formats

  • PDF, rendered with MuPDF (faster, more modern, and supports more formats than XPDF used in BePDF), also encrypted files.
  • EPUB 2 and 3: laid out for a text size (pages stay where your reading is when you change it). Not yet: fixed-layout EPUB and DRM.
  • Comic books: CBZ, CBR, CB7, CBT and the new Bound Book Format (BBF), with double pages, manga reading order (right to left), and webtoons (top to bottom), ComicInfo.xml metadata and the cover.
  • DjVu, with its text layer: search, selection and marks work.
  • XPS, FictionBook and pictures through MuPDF.

Annotating

Highlight, underline and strike out text in colors, add margin notes, free notes, text, rectangles, ellipses, lines, arrows, and drawings with line width and fill. Toolbar buttons arm a tool (marker colors, note, shapes), and text can be selected over several pages. In a PDF the annotations are normal PDF annotations that other readers show; for EPUB, comics and DjVu they are kept
with the file.

Semantic features and BFS/HFS

  • Annotations as W3C Web Annotations: every annotation is described in the W3C Web Annotation model (targets with page, region, quoted words or EPUB CFI), stored as BFS attributes of the file (SEN:annotations), so other programs can find and
    use them without opening the document. Bookmarks are annotations, too. Every annotation has a stable identifier.
  • Native BFS metadata: title, author, series, language, ISBN, date, the number of pages and more are written as BFS attributes with standard names following established universal schemas/ontologies (dc:title, dc:creator, schema:isbn, …), so Tracker can show them as columns and queries can find them. Reading progress is kept with the file.
  • Places in documents: Toji opens a document at an exact place (a page, a region, words, an EPUB position, an annotation) with the standard fragments, from the command line (Toji <file>#page=5), from a message or with Goto in the scripting suite.
    Copy link to this place makes a toji: link for it. These links hold a file path, which can change; stable links that name a document by its SEN:ID (a sen:// handler) are coming with SEN later this year (yes, really now, seriously:).
  • Scripting: the document, its pages, annotations and bookmarks can be read and changed with hey Toji ... or with scripting messages from your own programs (get and set the note or the words of a mark, create annotations, go to a place, save).

A showcase for SEN

Toji is a daily reader and an entry point to SEN (Semantic Extensions Native), which brings semantic relations to Haiku files and documents. It shows how file attributes, open standards and messages can work together on Haiku. More about SEN later this year.

Install

pkgman add-repo https://kiri.sen-labs.org/x86_64
pkgman install toji

The libraries it needs (MuPDF from the same repository, and libarchive, libzip, libxml2, DjVuLibre and FreeType from the Haiku repositories) are installed with it, and it replaces Tsundoku if you have that. A user guide (PDF, EPUB, DjVu, HTML) is built from Markdown and comes with it; Help opens it. The package is also attached to the release.

Licenses

Toji is free software under the AGPL-3.0-or-later (MuPDF is AGPL, BePDF GPL-2+). The reusable parts (the Web Annotation model,
bookmarks, the EPUB, ComicInfo and BBF readers, EPUB CFI, links) are in a separate folder, lib/, under the MIT license, so
other programs can use them. The artwork is CC BY 4.0, and every file has an SPDX identifier (REUSE compliant).

Source and status

:backhand_index_pointing_right: GitHub - sen-laboratories/toji: Toji is a document reader for Haiku, extended for SEN, for reading, annotating, and linking your thoughts - from Tsundoku to Tori. · GitHub

It is a beta: the features are in and usable, and are being tested on Haiku R1/beta6. Bug reports, ideas and feedback are very welcome, especially from people who read EPUB or comics on Haiku, work with scanned DjVu documents, or want to script their documents.

About the use of AI

As those brave souls of you waiting for SEN have painfully noticed, my ambition wildly outpaces my time and energy resources. Add to it my unwavering self-made scope-creep, overthinking and perfectionism, and you will understand my relief when discovering how darn good these AI coding agents have become.

I use these as tools to carefully craft my vision into reliable, beautiful, maintainable code, not as prompt-to-slop-engines. I am still a computer scientist and developer by heart, but I want to see my vision come true in this lifetime.

For a more detailed stance, please have a look at this manifesto on the new SEN blog.

18 Likes

Hi @grexe

This sounds like an awesome project. Will definitely give it a try!

Thank you for working on this!

1 Like

There were issues with BePDF on my Haiku 64 bit, but as there was Okular available I replaced it with that one.

On linux previously I had a comic reader and some book reader too, but I never had a light device to use for reading with comfort. The last time I was in comfort with digital bookstore I had a PDA just at the same time the iPhone-craziness has just started - in 2007, and prolonged in 2008 -, when I put there all Asimov and finally I finished with robot and foundation stories there.

So thank you for this software - may some time Haiku can be used on real portable devices thanks to ARM or RISC-V, and then I can use it to read books or comics again. Especially if I would have such digital content again.

:cowboy_hat_face:

1 Like