Skip to main content
When a document’s encrypt block is set, the viewer can decrypt text in-browser before rendering.

Detection

The loader calls hasEncryptedContent(doc) on every load. If encrypted content is detected, one of two flows runs:
  1. Password in config — if password was passed in config, it’s used to decrypt in-memory.
  2. Password modal — otherwise a PasswordModal component is rendered, prompting the user.

JavaScript

Svelte

Programmatic helpers

Imported from the library:

Errors

When a wrong password is supplied, the viewer calls onError with a LoaderError carrying code: 'DECRYPT_FAILED'. The modal flow retries until the user cancels or succeeds.