Example
await instance.load({ document: '/other.pdf' });
await instance.load({ document: '/secret.pdf', password: 's3cret' });
Properties
The document to load, as a URL string or an ArrayBuffer — the same values
Configuration#document accepts in Standalone mode.
ArrayBuffers are transferred to the WebAssembly engine and must not be reused
afterwards, exactly as for NutrientViewer.load.
initialViewState
The view the new document opens at, mirroring Configuration#initialViewState. When omitted, the new document opens at its own defaults: the first page, NutrientViewer.ZoomMode.AUTO, no page rotation.
Only the part of a ViewState that describes the document view applies — the page
index, zoom, page rotation, layout and scroll mode, spacing and padding, plus
commentDisplay, disablePointSnapping, forceRenderWidgetsInAnnotationsOrder,
keepFirstSpreadAsSinglePage and prerenderedPageSpreads. The rest of a
ViewState describes the viewer (the sidebar, toolbar visibility, read-only mode, the
interaction mode), and the viewer is what NutrientViewer.Instance#load preserves;
use NutrientViewer.Instance#setViewState for those.
Validation follows NutrientViewer.load: a malformed view state rejects before the
current document is touched, while a value that only the new document can invalidate falls
back to that field's default — an out-of-bounds currentPageIndex opens page 1, a custom
zoom outside the new document's range becomes NutrientViewer.ZoomMode.AUTO — with a
console warning.
Derive it from NutrientViewer.Instance#viewState rather than constructing a fresh
ViewState: a hand-built one carries the defaults for every shell field, so on any
viewer that is not already at them — a sidebar open, a read-only document — it reads as a
request to change the viewer and is rejected. This includes sidebarWidth: 0 when the
current sidebar has a nonzero width. Viewer fields are compared when load() is called,
before the request enters the queue, so later viewer changes cannot invalidate it.
Example
await instance.load({
document: '/other.pdf',
initialViewState: instance.viewState.set('currentPageIndex', 2),
});
Default Value
password
The password for a protected document, mirroring Configuration#password. It gets exactly one attempt.
When omitted, the instance's configured
Configuration#onPasswordRequired callback is consulted once instead.
Unlike NutrientViewer.load, the interactive password prompt is never shown, so
Configuration#maxPasswordRetries does not apply and neither does
headless. A wrong or missing password rejects the call and leaves the current document
open. A document that goes to OPFS storage is the exception: the current document is
already closed when its password is checked, and a prompt over a closed document that the
user can cancel into nothing is worse than a rejection the host can handle. Passing a
password here does not fall back to the callback — a caller who passes one has declared it
knows the right one.
The configuration accepted by NutrientViewer.Instance#load, which loads another document into a viewer that is already on screen.
It is a deliberately narrow subset of Configuration: the keys here describe the document, and they mean exactly what they mean for NutrientViewer.load. Everything else in
Configurationdescribes the viewer itself — the container, the license, the toolbar, the theme, the locale — and that viewer is precisely what NutrientViewer.Instance#load reuses, so passing any other key is an error rather than a silently ignored no-op.The rejection is enforced at compile time as well as at runtime: Instance#load additionally declares every other
Configurationkey asnever, so spreading a bootstrap configuration —instance.load({ ...bootstrapConfiguration, document }), where excess-property checking does not apply — is a type error rather than a runtime one.