Table of Contents

Method RedactToBytes

Namespace
LMKit.Document.OpenXml
Assembly
LM-Kit.NET.dll

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

data byte[]

The source document bytes.

extension string

The file extension naming the document format, such as ".docx", ".xlsx" or ".pptx". The leading dot is optional and casing is ignored.

request OfficeRedactionRequest

What to redact.

options OfficeRedactionOptions

Optional redaction options; defaults are used when null.

cancellationToken CancellationToken

Cancellation token.

Returns

OfficeRedactionResult

The redacted bytes and the report describing what was overwritten.

Exceptions

ArgumentNullException

Thrown when data or request is null.

ArgumentException

Thrown when extension is null or whitespace.

NotSupportedException

Thrown when extension names 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

inputPath string

File-system path to the source document.

request OfficeRedactionRequest

What to redact.

options OfficeRedactionOptions

Optional redaction options; defaults are used when null.

cancellationToken CancellationToken

Cancellation token.

Returns

OfficeRedactionResult

The redacted bytes and the report describing what was overwritten.

Exceptions

ArgumentException

Thrown when inputPath is null or whitespace.

ArgumentNullException

Thrown when request is null.

FileNotFoundException

Thrown when inputPath does 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

attachment Attachment

The attachment carrying the source document.

request OfficeRedactionRequest

What to redact.

options OfficeRedactionOptions

Optional redaction options; defaults are used when null.

cancellationToken CancellationToken

Cancellation token.

Returns

OfficeRedactionResult

The redacted bytes and the report describing what was overwritten.

Exceptions

ArgumentNullException

Thrown when attachment or request is null.

NotSupportedException

Thrown when the attachment carries a format other than .docx, .xlsx or .pptx.

Share