# EPUB.JS Documentation ## Methods #### ePub(bookPath, options) Creates a new EPUBJS.Book() bookPath is a optional convience method that will start loading the book at that given path ```javascript var Book = ePub("url/to/book/"); // With default options ``` ```javascript var Book = ePub({ restore: true }); Book.open("url/to/book/"); // Books can be opened later ``` Options: ```javascript { bookPath : null, version: 1, // Changing will cause stored Book information to be reloaded restore: false, // Skips parsing epub contents, loading from localstorage instead storage: false, // true (auto) or false (none) | override: 'ram', 'websqldatabase', 'indexeddb', 'filesystem' spreads: true, // Displays two columns fixedLayout : false, //-- Will turn off pagination styles : {}, // Styles to be applied to epub width : false, height: false, } ``` Intially you'll probably just want to turn on restore. The width and height will be set to the containing element's dimensions. ```javascript var Book = ePub("url/to/book/", { restore: true }); ``` The following examples will refer to this ePub variable as ```Book```. #### Book.open(bookPath) Will open and parse a book at the given path. ```javascript var Book = ePub({ restore: true }); Book.open("url/to/book/"); // Books can be opened later ``` Books can be compressed epub. See section X for additional information about handling these ```javascript Book.open("url/to/book.epub"); ``` #### Book.renderTo(element) Appends the iframe that will contain the rendered book to a element. Returns a promise with the render object after the first chapter has been loaded ```javascript var Book = ePub("url/to/book/", { restore: true }); var $el = document.getElementById("div-id"); Book.renderTo($el); ``` renderTo can take a element id as a string. ```javascript var Book = ePub("url/to/book/"); Book.renderTo("div-id"); ``` #### Book.nextPage() #### Book.prevPage() Changes the page the book is on. If on the first or last page of a chapter, the next chapter will be loaded. ```html