-
CoreViewer
addListener(type, listener)
getCurrentPageProgression()
getPageSizes()
isTOCVisible()
loadDocument(singleDocumentOptions, documentOptions, viewerOptions)
loadPublication(pubURL, documentOptions, viewerOptions)
navigateToInternalUrl()
navigateToPage()
queryZoomFactor(type)
removeListener(type, listener)
setOptions(options)
showTOC(opt_show, opt_autohide)
Enum PageProgression
represents page progression direction.
PageProgression
has members, LTR
and RTL
.
Enum PageSide
represents page side.
PageSide
has members, LEFT
and RIGHT
.
Enum ReadyState
represents viewer ready state.
ReadyState
has members, LOADING
, INTERACTIVE
and COMPLETE
.
Register a function to a hook with the specified name. The registered function is called at appropriate timings by the core code. Arguments passed to the function depend on the hook. When multiple functions are registered, they are called by the order in which they are registered.
name
(string) β Name of the hook.fn
(function) β Function to be registered to the hook.
Remove a function already registered to the specified name. Note that even if the same function are registered multiple times, this method removes only the first one.
name
(string) β Name of the hook.fn
(function) β Function to be removed from the hook.
Registers start timing of some event.
name
(string) β Name of event.timestamp
(number, optional) β Used as the actual timestamp of the event if specified, instead of "now".
Registers end timing of some event.
name
(string) β Name of event.timestamp
(number, optional) β Used as the actual timestamp of the event if specified, instead of "now".
Log registered timings (start/end/duration). All values are printed in ms unit.
Disable profiling.
Enable profiling.
Vivliostyle CoreViewer class. Creates CoreViewer
.
settings
(CoreViewerSettings)options
(CoreViewerOptions, optional)
Enum PageViewMode
.
PageViewMode
has members, SINGLE_PAGE
, SPREAD
and AUTO_SPREAD
.
Enum ZoomType
.
ZoomType
has only one member, FIT_INSIDE_VIEWPORT
.
Add a listener function, which is invoked when the specified type of event is dispatched.
type
(string) β Event type.listener
(function) β Listener function.
Returns the current page progression of the viewer. If no document is loaded, returns null.
Array<{width: number, height: number}>
Returns true if TOC is visible, false if hidden, null if TOC is unavailable
Load an HTML or XML document(s).
singleDocumentOptions
(SingleDocumentOptions|Array<SingleDocumentOptions>)documentOptions
(DocumentOptions, optional)viewerOptions
(CoreViewerOptions, optional)
Load a EPUB/WebPub publication.
pubURL
(string)documentOptions
(DocumentOptions, optional)viewerOptions
(CoreViewerOptions, optional)
Navigate to the specified internal URL.
Navigate to the specified page.
Returns zoom factor corresponding to the specified zoom type.
type
(ZoomType)
number
Remove an event listener.
type
(string) β Event type.listener
(function) β Listener function.
Set CoreViewerOptions to the viewer.
options
(CoreViewerOptions)
Show or hide TOC box
opt_show
(boolean) - If true show TOC, false hide TOC. If null or undefined toggle TOC.opt_autohide
(boolean) - If true, automatically hide when click TOC item
Options for the displayed document.
documentObject
(Document, optional) β Document object for the document. If provided, it is used directly without parsing the source again.fragment
(string, optional) β Fragmentation identifier (EPUB CFI) of the location in the document which is to be displayed.authorStyleSheet
(Array<string>
, optional) β An array of author style sheets to be injected after all author style sheets referenced from the document. A single stylesheet may be a URL of the style sheet or a text content of the style sheet.userStyleSheet
(Array<string>
, optional) β An array of user style sheets to be injected. A single stylesheet may be a URL of the style sheet or a text content of the style sheet.
Options for a single source document.
SingleDocumentOptions
is the object that has members below, or otherwise string that represents url
.
url
(string) β URL of the document.startPage
(number, optional) β If specified, thepage
page-based counter is set to the specified value on the first page of the document. It is equivalent to specifyingcounter-reset: page [specified value - 1]
on that page.skipPagesBefore
(number, optional) β If specified, thepage
page-based counter is incremented by the specified value before updating page-based counters on the first page of the document. This option is ignored ifstartPageNumber
option is also specified.
CoreViewer settings that must be passed to CoreViewer's constructor.
viewportElement
(HTMLElement, required) β An element used as the viewport of the displayed contents.userAgentRootURL
(string, optional) β URL of a directory from which viewer resource files (under resources/ directory in the source repository) are served.window
(Window, optional) β Window object. If omitted, currentwindow
is used.debug
(boolean, optional) β Debug flag.
Viewer options that can be set after the Viewer object is constructed.
autoResize
(boolean, optional) β Run layout again when the window is resized. default: truefontSize
(number, optional) β Default font size (px). default: 16pageBorderWidth
(number, optional) β Width of a border between two pages in a single spread (px). Effective only in spread view mode. default: 1renderAllPages
(boolean, optional) β Render all pages at the document load time. default: truepageViewMode
(PageViewMode, optional) β Page view mode (singlePage / spread / autoSpread). default: singlePagezoom
(number, optional) β Zoom factor with which pages are displayed. default: 1fitToScreen
(boolean, optional) β Auto adjust zoom factor to fit the screen. default: falsedefaultPaperSize
({width: number, height: number}, optional) β Default paper size in px. Effective when @page size is set to auto. default: undefined (means the windows size is used as paper size).
Allows page-layouting using the vivliostyle for printing within a website without destroying the original layout
import { printHTML } from '@vivliostyle/core';
const htmlDoc = `<!doctype html>
<html>
<head>
<style>
... Add your CSS code here ...
</style>
</head>
<body>
... Add your HTML code here ...
</body>
</html>`;
const config = {
title: 'My printed page',
printCallback: (iframeWin) => iframeWin.print(), // optional: only needed if calling something other than window.print() for printing.
};
printHTML(htmlDoc, config);