readium / SDKLauncher-iOS

A small iOS application to serve as a launcher/testbed for the Readium SDK.
BSD 3-Clause "New" or "Revised" License
71 stars 47 forks source link

Jump to a specific paragraph #61

Open higginator opened 9 years ago

higginator commented 9 years ago

Hello.

Is there a way to jump to a specific paragraph within an epub? My end goal is to sync 2 books. When a user highlights a word in book1, I would like to know the paragraph id that this word belongs to. And then I would like to load book2, jumping to the location of the paragraph with the same id.

I see that I can do this on a page by page basis, using each spineItem's spineItemIndex and spineItemPageIndex and initializing/pushing to the navigationController a new EPubViewController. But I would like to narrow in to the paragraph level.

(Just thinking now...perhaps this would require giving each paragraph an id attribute when the epub's are being authored. <p id=1'>.......)

rkwright commented 9 years ago

The short answer is that you can target specific paragraphs in a unique fashion using CFIs (Canonical Fragment Identifiers). See http://www.idpf.org/epub/linking/cfi/epub-cfi.html.
The long answer will require some research and experimentation.

danielweck commented 9 years ago

You may also be interested in an upcoming EPUB3 feature called "Multiple Renditions" and in particular the "Mapping Document": http://www.idpf.org/epub/renditions/multiple/ There is an experimental implementation in ReadiumJS, see the epub3MultipleRenditions feature branch: https://github.com/readium/readium-js-viewer/tree/feature/epub3MultipleRenditions https://github.com/readium/readium-js/tree/feature/epub3MultipleRenditions https://github.com/readium/readium-shared-js/tree/feature/epub3MultipleRenditions