CFI when clicking or selecting a text.

4 posts / 0 new
Last post


I would like to know if there is a way to get a CFI when the user clicks on a text or even a CFI range when he chooses some text.
Is it also possible to directly go to a section of a text by providing a CFI?

I tried to figure it out by looking at the code but so far couldn't really understand the entry points and the overall architecture (I'm using readium-js-viewer)


Hi Franck,

First you need to get a reference to the `reader` object as this is an entry point into Readium's Reader API.

The EpubReader.js script holds a reference to this via `readium.reader`, `readium` being a local variable.

You can also obtain a reference globally through `ReadiumSDK.reader`.

To get a CFI based on the user's selection you can call `reader.getCurrentSelectionCfi()`
This will give you undefined if nothing is selected or an object with idref and cfi properties.

You can navigate to this CFI by using `reader.openSpineItemElementCfi(idref, cfi)`

in my comic epub file "internal linking" is not working for example: window.location(xyz.xhtml) this line of code is link to another page not work properly in Readium 2.18.1.if you have any solution ,please let me know,


@sanketmunj:  Please do not post to other posts.  Please create a new forum entry for new questions.  In this case, please do that.  Can you share the EPUB with us?  Internal links should work fine.

Secondary menu