The redaction object is an instance accessible from the main mupdfwv.MuPDFWebViewer instance as follows:
const redaction = mupdf.redaction;
This assumes you have returned your instance name as mupdf from the initMuPDFWebViewer() promise!

redaction

The redaction object has the following methods:

get

get(config?: { textData: mupdf.refs.redaction.textDataOption }) Returns array of (unapplied) redactions for the document.
  • Arguments:
    • config(optional) The configuration object. If undefined returns all redactions for all pages.
Config object:
  • Arguments:
    • textData(required) The text data option for the redaction.
  • Returns: Promise<Redaction[]>.
Example
mupdf.redaction.get();
Note: if redactions have been previously applied then these redactions are permananent and, as we should expect, will not be returned!The Redaction[] array is an array of redaction objects.

set

set(config: { redactions: Redaction[] }) Updates redactions.
  • Arguments:
    • config(required) The configuration object.
Config object:
  • Arguments:
    • redactions(required) An array of redaction objects.
The Redaction[] array is an array of redaction objects.

add

add(config: { redactions: Redaction[] }) Adds redactions.
  • Arguments:
    • config(required) The configuration object.
Config object:

remove

remove(config: { redactions: Redaction[] }) Removes redactions.
  • Arguments:
    • config(required) The configuration object.
Config object: For the redaction objects you just need to set oid or name and pageIndex for the unique key. Then the redaction will be removed.

apply

apply(config: { redactions: Redaction[] }) Applies redactions.
  • Arguments:
    • config(required) The configuration object.
Config object: For the redaction objects you just need to set oid or name and pageIndex for the unique key. Then the redaction will be applied.

Redaction Object

The Redaction object is a JSON object as follows:
{
  oid: number;
  pageIndex: number;
  name: string;
  rect?: TRect;
  opacity?: number;
  author?: string;
  canBePrinted?: boolean;
  locked?: boolean;
}
  • oid (required): Object id
  • pageIndex (required): Page index
  • name (required): Unique name in the page
  • rect (optional): Rectangle { top: number, left: number, bottom: number, right: number }
  • opacity (optional): Opacity (0.0 ~ 1.0)
  • author (optional): Author
  • canBePrinted (optional): Whether to be printed
  • locked (optional): Whether to be locked
You need to set oid or name and pageIndex as the unique key. Then the property will be updated.