Closed Supalet closed 3 years ago
thank @mickael-menu. I would like to ask 1 more question. Can the library get all page numbers in the chapter and page numbers in the currently open chapter?
Yes, we call these "positions" in our architecture, see https://github.com/readium/architecture/tree/master/models/locators/positions
You can use it like that:
// Total number of positions in the publication
let totalPositions = publication.positionList.count
// Total number of positions in one chapter
let totalPositionsInResource = publication.positionListByResource[href].count
func navigator(_ navigator: Navigator, locationDidChange locator: Locator) {
// Current position in the visible resource (starting from 1)
locator.locations.position
}
(Note: positionList
is named positions
on the develop
branch)
I use locator.locations.position this last page book but i get prosition 19 not 25.
That's normal, we can have more (or less) positions per "screen page", so the last page in this case contains 6 positions, and we report the first position in it (19).
Unfortunately, we don't have any reliable way to report real screen page numbers for reflowable EPUBs, because it depends on the size of the screen, user settings, font size, etc. We could calculate it for the current chapter, but not for the whole publication, so that would be pointless.
If by chapter you mean from the table of contents, then it's not possible at the moment.
However, if you mean the current resource, then: