-
Notifications
You must be signed in to change notification settings - Fork 34
Reader API
Aferdita Muriqi edited this page May 25, 2020
·
4 revisions
D2Reader.applyUserSettings(<#json#>)
json = {
fontSize: number
fontOverride: boolean
fontFamily: number
appearance: string
verticalScroll: boolean
publisherDefaults: boolean
textAlignment: number
columnCount: number
wordSpacing: number
letterSpacing: number
pageMargins: number
lineHeight: number
}
<button onclick="javascript:D2Reader.applyUserSettings({appearance:'day',fontSize:100, fontFamily:'opendyslexic', letterSpacing:0.25, textAlignment:'justify'})">apply multiple settings</button>
<button onclick="javascript:D2Reader.applyUserSettings({appearance:'day'})">day</button>
<button onclick="javascript:D2Reader.applyUserSettings({appearance:'sepia'})">sepia</button>
<button onclick="javascript:D2Reader.applyUserSettings({appearance:'night'})">night</button>
<button onclick="javascript:D2Reader.applyUserSettings({fontSize:100})">font size 100</button>
<button onclick="javascript:D2Reader.applyUserSettings({fontSize:150})">font size 150</button>
<button onclick="javascript:D2Reader.applyUserSettings({fontSize:200})">font size 200</button>
<button onclick="javascript:D2Reader.applyUserSettings({fontFamily:'Courier'})">font family Courier</button>
<button onclick="javascript:D2Reader.applyUserSettings({fontFamily:'serif'})">font family serif</button>
<button onclick="javascript:D2Reader.applyUserSettings({fontFamily:'opendyslexic'})">font family opendyslexic</button>
<button onclick="javascript:D2Reader.applyUserSettings({wordSpacing:0.25})">word spacing 0.25</button>
<button onclick="javascript:D2Reader.applyUserSettings({letterSpacing:0.25})">letter spacing 0.25</button>
<button onclick="javascript:D2Reader.applyUserSettings({columnCount:'1'})">column 1</button>
<button onclick="javascript:D2Reader.applyUserSettings({columnCount:'auto'})">column auto</button>
<button onclick="javascript:D2Reader.applyUserSettings({textAlignment:'justify'})">align justify</button>
<button onclick="javascript:D2Reader.applyUserSettings({textAlignment:'start'})">align start</button>
D2Reader.publisher(<#bool#>)
bool = true / false
true = uses publisher default style
false = uses custom style (i.e. letterSpacing etc.)
<button onclick="javascript:D2Reader.publisher(true)">publisher default</button>
<button onclick="javascript:D2Reader.publisher(false)">custom style</button>
D2Reader.increase(<#string#>)
string = fontSize / letterSpacing / wordSpacing
<button onclick="javascript:D2Reader.increase('wordSpacing')">word spacing increase</button>
D2Reader.decrease(<#string#>)
string = fontSize or letterSpacing or wordSpacing
<button onclick="javascript:D2Reader.decrease('wordSpacing')">word spacing increase</button>
D2Reader.resetUserSettings()
<button onclick="javascript:D2Reader.resetUserSettings()">reset user setting</button>
D2Reader.previousResource()
<button onclick="javascript:D2Reader.previousResource()">previous resource</button>
D2Reader.nextResource()
<button onclick="javascript:D2Reader.nextResource()">next resource</button>
D2Reader.previousPage()
<button onclick="javascript:D2Reader.previousPage()">previous page</button>
D2Reader.nextPage()
<button onclick="javascript:D2Reader.nextPage()">next page</button>
D2Reader.scroll(<#bool#>)
<button onclick="javascript:D2Reader.scroll(true)">scroll</button>
<button onclick="javascript:D2Reader.scroll(false)">paginated</button>
D2Reader.goTo(<#locator#>)
<button onclick="javascript:D2Reader.goTo({href:'OEBPS/Text/front.xhtml', title:'frontpage', locations:{progression:0}})">go to frontpage</button>
D2Reader.tableOfContents()
<button onclick="javascript:D2Reader.tableOfContents().then(result => {
console.log(result)
console.log(result.length)
})">show table of contents</button>
D2Reader.bookmarks()
<button onclick="javascript:D2Reader.bookmarks().then(result => {
console.log(result)
console.log(result.length)
})">show booksmarks</button>
D2Reader.annotations()
<button onclick="javascript:D2Reader.annotations().then(result => {
console.log(result)
console.log(result.length)
})">show annotations</button>
D2Reader.totalResources()
number of total resources
<button onclick="javascript:alert(D2Reader.totalResources())">totalResources</button>
D2Reader.currentResource
index of current resource
<button onclick="javascript:alert(D2Reader.currentResource())">currentResource</button>
D2Reader.mostRecentNavigatedTocItem
most recent toc href
<button onclick="javascript:alert(D2Reader.mostRecentNavigatedTocItem())">mostRecentNavigatedTocItem</button>
D2Reader.saveBookmark()
<button onclick="javascript:D2Reader.saveBookmark()">add bookmark</button>
D2Reader.deleteBookmark(<#json#>)
<button onclick="javascript:D2Reader.deleteBookmark({id:123})">delete bookmark</button>
D2Reader.deleteAnnotation(<#json#>)
<button onclick="javascript:D2Reader.deleteAnnotation({id:123})">delete annotation</button>
- GitHub Package
- Initialize Reader
-
Injectables
- Readium CSS
- Footnotes
- Glossary
- Fonts
- Pagebreak
- Injectable Context Menu
-
Reader API
- User Settings API
- Navigator API
- Bookmark API
- Annotation API
- TTS API
- Search API
- Callback API
-
Modules
- Bookmarks
- Annotations
- Search
- TTS