Method RedactToBytes
RedactToBytes(byte[], string, OfficeRedactionRequest, OfficeRedactionOptions, CancellationToken)
Redacts in-memory Office document bytes and returns the redacted bytes together with the report.
public static OfficeRedactionResult RedactToBytes(byte[] data, string extension, OfficeRedactionRequest request, OfficeRedactionOptions options = null, CancellationToken cancellationToken = default)
Parameters
databyte[]The source document bytes.
extensionstringThe file extension naming the document format, such as
".docx",".xlsx"or".pptx". The leading dot is optional and casing is ignored.requestOfficeRedactionRequestWhat to redact.
optionsOfficeRedactionOptionsOptional redaction options; defaults are used when
null.cancellationTokenCancellationTokenCancellation token.
Returns
- OfficeRedactionResult
The redacted bytes and the report describing what was overwritten.
Exceptions
- ArgumentNullException
Thrown when
dataorrequestis null.- ArgumentException
Thrown when
extensionis null or whitespace.- NotSupportedException
Thrown when
extensionnames a format other than .docx, .xlsx or .pptx.
RedactToBytes(string, OfficeRedactionRequest, OfficeRedactionOptions, CancellationToken)
Redacts the Office document at inputPath and
returns the redacted bytes together with the report. The format is
taken from the path's extension.
public static OfficeRedactionResult RedactToBytes(string inputPath, OfficeRedactionRequest request, OfficeRedactionOptions options = null, CancellationToken cancellationToken = default)
Parameters
inputPathstringFile-system path to the source document.
requestOfficeRedactionRequestWhat to redact.
optionsOfficeRedactionOptionsOptional redaction options; defaults are used when
null.cancellationTokenCancellationTokenCancellation token.
Returns
- OfficeRedactionResult
The redacted bytes and the report describing what was overwritten.
Exceptions
- ArgumentException
Thrown when
inputPathis null or whitespace.- ArgumentNullException
Thrown when
requestis null.- FileNotFoundException
Thrown when
inputPathdoes not exist.- NotSupportedException
Thrown when the path's extension names a format other than .docx, .xlsx or .pptx.
RedactToBytes(Attachment, OfficeRedactionRequest, OfficeRedactionOptions, CancellationToken)
Redacts the Office document carried by attachment
and returns the redacted bytes together with the report. The format
is taken from the attachment's detected MIME type, falling back to
its name's extension.
public static OfficeRedactionResult RedactToBytes(Attachment attachment, OfficeRedactionRequest request, OfficeRedactionOptions options = null, CancellationToken cancellationToken = default)
Parameters
attachmentAttachmentThe attachment carrying the source document.
requestOfficeRedactionRequestWhat to redact.
optionsOfficeRedactionOptionsOptional redaction options; defaults are used when
null.cancellationTokenCancellationTokenCancellation token.
Returns
- OfficeRedactionResult
The redacted bytes and the report describing what was overwritten.
Exceptions
- ArgumentNullException
Thrown when
attachmentorrequestis null.- NotSupportedException
Thrown when the attachment carries a format other than .docx, .xlsx or .pptx.