Pagination
reader.pagination gives you access to the current book pagination information. It can be used to know which page is being read, how many pages are in a chapters or other such information.
type PaginationInfo
type PaginationInfotype PaginationInfo = {
beginCfi: string | undefined
beginSpineItemIndex: number | undefined
beginChapterInfo: ChapterInfo | undefined
beginPageIndexInSpineItem: number | undefined
beginNumberOfPagesInSpineItem: number | undefined
beginSpineItemReadingDirection: `rtl` | `ltr` | undefined
beginAbsolutePageIndex: number | undefined
endCfi: string | undefined
endSpineItemIndex: number | undefined
endChapterInfo: ChapterInfo | undefined
endPageIndexInSpineItem: number | undefined
endNumberOfPagesInSpineItem: number
endSpineItemReadingDirection: `rtl` | `ltr` | undefined
endAbsolutePageIndex: number | undefined
/*
* This percentage is based of the weight (kb) of every items and the number of pages.
* It is not accurate but gives a general good idea of the overall progress.
*/
percentageEstimateOfBook: number | undefined
/**
* This value is only correct for pre-paginated books and or
* if you preload the entire book in case of reflow. This is because
* items get loaded unloaded when navigating through the book, meaning
* we cannot measure the number of pages accurately.
*/
numberOfTotalPages: number | undefined
isUsingSpread: boolean
canGoLeft: boolean
canGoRight: boolean
}pagination.paginationInfo$
pagination.paginationInfo$Observable that emit whenever a new valid pagination info is updated. It will not emit invalid pagination.
Examples
Save current cfi into localStorage for loading a book at the previous location:
pagination.getPaginationInfo()
pagination.getPaginationInfo()Static method to return the pagination info. Be careful since it can return an invalid pagination (For example if no book is loaded).
Last updated
Was this helpful?