viewer
object is an instance accessible from the main mupdfwv.MuPDFWebViewer instance as follows:
mupdf
from the initMuPDFWebViewer() promise!viewer
object has the following methods:
setColor(config: {mainColor: string, subColor: string})
Sets the primary (mainColor
) and secondary (subColor
) for the viewer user-interface.
string
in format “#RRGGBB”.string
in format “#RRGGBB”.Promise
.setBackgroundColor(config: {color: string})
Sets the background color behind the document page.
string
in format “#RRGGBB”.Promise
.viewer.setPageBorderColor(config: {color: string})
Sets the border color around document page instances in the viewer.
string
in format “#RRGGBB”.Promise
.setTheme(config: {type: mupdf.refs.theme})
Sets the overall theme of the viewer UI.
Promise
.setLogo(config: {url: string})
Sets the brand logo (maximum size: 100x24px). It displays the logo in the top center of the viewer.
string
.Promise
.toggleDialog(config: { dialogType: mupdf.refs.dialog.type, visibility?: boolean })
Toggles, shows or hides the print or search dialog.
boolean
. Use to explicity show or hide instead of toggle.Promise
.getScale()
Gets the current zoom scale.
Promise<{ scale: number; }>
.setScale(config: { scale: number })
Sets the current zoom scale.
Promise
.viewer.zoomIn(config?: { increment?: number })
Zooms in on the document.
Promise
.viewer.zoomOut(config?: { decrement?: number })
Zooms out on the document.
Promise
.getCurrentPageIndex()
Gets the current page index (zero-indexed).
Promise<{ currentPageIndex: number; }>
.getRotation()
Gets the current document rotation angle in degrees.
Promise
.setRotation(config: { degree: mupdf.refs.degree })
Sets the document rotation angle in degrees.
Promise
.rotateClockwise()
Rotates clockwise.
Promise
.rotateCounterClockwise()
Rotates counter-clockwise.
Promise
.setViewMode(config: { viewMode: mupdf.refs.viewMode })
Sets the view mode for the document.
Promise
.fitTo(config: { to: mupdf.refs.fit.to })
Sets the page fitting.
Promise
.scrollToNextPage()
Scrolls to the next page.
Promise
.scrollToPreviousPage()
Scrolls to the previous page.
Promise
.scrollTo(config: { type: mupdf.refs.scroll.type, value: number, centerPoint?: { x: number, y: number }, select?: boolean, name?: string, pageIndex?: number })
Scrolls to a specific position on a page or to an annotation.
PAGE
: Page index, zero-indexed, ANNOTATION
: Annotation id).type
is mupdf.refs.scroll.type.PAGE
).type
is mupdf.refs.scroll.type.ANNOTATION
).type
is mupdf.refs.scroll.type.ANNOTATION
).type
is mupdf.refs.scroll.type.ANNOTATION
).Promise
.openSideView(config: { type: mupdf.refs.panel.open })
Opens a side view panel.
Promise
.closeSideView(config: { type: mupdf.refs.panel.close })
Closes a side view panel.
Promise
.togglePanel(config: { type: mupdf.refs.panel.open })
Toggles a panel visibility.
Promise
.
highlight(config: { rects: Array<{ color: string; pageIndex: number; opacity?: number; rect: { top: number; left: number; bottom: number; right: number } }> })
Highlights text.
Promise<mupdfwv.HighlightedRect[]>
.unhighlight(config:{ rects: { id: number }[] })
Removes highlights.
Promise
.searchText(config: { keyword: string; caseSensitive?: boolean; useRegex?: boolean; emitEvent?: boolean })
Searches for text. This will open up the search panel if it is not already opened and run the search.
Promise
.setLanguage(config: { key: mupdf.refs.language })
Sets the language for the UI.
Promise
.getSize()
Gets the viewer size.
Promise<{ width: number; height: number; }>
.setViewVisibility(config: { view: mupdf.refs.visibility.view, visibility: boolean })
Sets a view visibility.
mupdf.refs.visibility.view
should be one of TOOLBAR
| FLOATING_NAV
| SIDE_VIEW
| CONTEXT_MENU
| INDICATOR
.Promise
.viewer.addButton(config: { buttons: Array<{ position: string, icon: mupdf.refs.icon, label: string, onclick: Function }> })
Adds button items to the toolbar.
buttons
array objects:
Promise
.viewer.addContextMenu(config: { menus: Array<{ type: string, position: string, icon?: mupdf.refs.icon, label?: string, onclick?: Function }> })
Adds items to the context menu (this is the pop-up menu you see when you right click on a document).
menus
array objects:
Promise
.defineDocumentPanel(config: { items: Array<{ label: string, onclick: Function, icon?: refs.icon }> })
Defines document panel at the left side of the viewer toolbar.
Config object:
items
array objects:
Promise
.
viewer.defineAnnotSelectMenu(config: { html: string; style?: string; script?: string; tool?: mupdf.refs.annotation.tool})
Defines the popup menu when selecting or creating an annotation.
Promise
.style
or script
, please consider the followingstyle
: CSS selectors will apply to all matching elements within the viewer scope.script
: JavaScript code will be executed in the viewer’s context with the following limitations:
openContextMenu()
Opens the context menu.
Promise
.