Web SDKv1.0.0

Helpers.createDropZone()

The viewer before a document. A host mounts the viewer and, until a file arrives, has nothing to show but a blank box; this is that box — a drop target, a file picker, and the privacy line.
static methodDocument statessince 1.0.0

Signature

createDropZone(container: HTMLElement, options: DropZoneOptions): DropZone

Parameters

ParameterTypeDescription
containerHTMLElementWhere the box is mounted — the element the viewer will later use.
optionsDropZoneOptions{ onFile, onReject?, title?, note?, action?, locale?, icons? }. onFile(file) receives a dropped or chosen PDF; onReject(file) a file that is not a PDF. title, note and action are the words shown; locale is the viewer's locale and icons its toolbar.icons.

Returns

DropZone { element, open(), destroy() } — open() opens the file picker, for a host shortcut such as Ctrl+O; destroy() once a document is open.

Example

TypeScript
const zone = createDropZone(container, { onFile: (file) => void openPdf(file) });
window.addEventListener('keydown', (e) => {
  if ((e.metaKey || e.ctrlKey) && e.key === 'o') zone.open();
});

More in Helpers