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
Optional configuration. If omitted, returns all redactions for all pages.
config.textData
webViewer.refs.redaction.textDataOption
required
The text data option for redactions. Required when config is provided.
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
The configuration object.
An array where each item requires oid, pageIndex, and name.
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
The configuration object.
An array where each item requires pageIndex and rect. oid and name are optional.
remove
remove ( config : {
redactions: {
oid: number ;
name : string ;
pageIndex : number ;
}[];
}): Promise < undefined > ;
Removes redactions.
Parameters
The configuration object.
An array where each item requires oid, name, and pageIndex.
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
The configuration object.
An array where each item requires oid, name, and pageIndex.
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 ;
}