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

redaction

The redaction object has the following methods:

get

get(config?: { textData: TextDataOption }): Promise<{ redactions: Annotation[] }>;
Returns an object containing (unapplied) redactions for the document.

Parameters

config
object
Optional configuration. If omitted, returns all redactions for all pages.

Returns

result
Promise<{ redactions: Annotation[] }>
required
A Promise that resolves to an object containing redactions.
Example
webViewer.redaction.get();
Note: if redactions have been previously applied then these redactions are permanent and, as we should expect, will not be returned!Use result.redactions to access the redaction array.

set

set(config: {
  redactions: {
    oid: number;
    pageIndex: number;
    name: string;
    rect?: TRect;
    opacity?: number;
    author?: string;
    canBePrinted?: boolean;
    locked?: boolean;
  }[];
}): Promise<undefined>;
Updates redactions.

Parameters

config
object
required
The configuration object.
Use this method to update existing redactions by unique identifier.

add

add(config: {
  redactions: {
    oid?: number;
    pageIndex: number;
    name?: string;
    rect: TRect;
    opacity?: number;
    author?: string;
    canBePrinted?: boolean;
    locked?: boolean;
  }[];
}): Promise<{ redactions: Annotation[] }>;
Adds redactions.

Parameters

config
object
required
The configuration object.

remove

remove(config: {
  redactions: {
    oid: number;
    name: string;
    pageIndex: number;
  }[];
}): Promise<undefined>;
Removes redactions.

Parameters

config
object
required
The configuration object.
Each redaction item must include oid, name, and pageIndex. Matching redactions are removed.

apply

apply(config: {
  redactions: {
    oid: number;
    name: string;
    pageIndex: number;
  }[];
}): Promise<undefined>;
Applies redactions.

Parameters

config
object
required
The configuration object.
Each redaction item must include oid, name, and pageIndex. Matching redactions are applied.

Redaction Types

The API uses different item shapes per method:
type SetRedaction = {
  oid: number;
  pageIndex: number;
  name: string;
  rect?: TRect;
  opacity?: number;
  author?: string;
  canBePrinted?: boolean;
  locked?: boolean;
};

type AddRedaction = {
  oid?: number;
  pageIndex: number;
  name?: string;
  rect: TRect;
  opacity?: number;
  author?: string;
  canBePrinted?: boolean;
  locked?: boolean;
};

type TargetRedaction = {
  oid: number;
  name: string;
  pageIndex: number;
};

Supporting Types

export interface TRect {
  top: number;
  left: number;
  right: number;
  bottom: number;
}