Table of Contents

Interface IPresentationEditor

Namespace
DocToolkit.Extensions.DependencyInjection
Assembly
DocToolkit.Extensions.DependencyInjection.dll

Creates, reads and edits PowerPoint (.pptx) presentations. Registered by AddDocToolkit(IServiceCollection, Action<DocToolkitOptions>?).

public interface IPresentationEditor

Methods

Create(IEnumerable<PptxSlide>)

Builds a deck from slides, one slide each — a title and bullet lines. Content comes from data rather than a template, so there is no source file to edit. An empty sequence is valid and produces a valid deck with no slides.

byte[] Create(IEnumerable<PptxSlide> slides)

Parameters

slides IEnumerable<PptxSlide>

Returns

byte[]

Exceptions

ArgumentNullException

slides is null.

ArgumentException

An element of slides is null.

DocumentConversionException

The deck could not be built.

CreateAsync(IEnumerable<PptxSlide>, Stream, CancellationToken)

Builds a deck from slides and writes it to destination. See Create(IEnumerable<PptxSlide>) for the slide semantics. destination is written and is neither disposed, closed nor sought, so an HTTP response body is a valid destination.

Task CreateAsync(IEnumerable<PptxSlide> slides, Stream destination, CancellationToken ct = default)

Parameters

slides IEnumerable<PptxSlide>
destination Stream
ct CancellationToken

Returns

Task

Exceptions

ArgumentNullException

slides or destination is null.

ArgumentException

An element of slides is null, or destination is not writable.

OperationCanceledException

ct was cancelled.

DocumentConversionException

The deck could not be built or written.

ExtractText(byte[])

All text found on every slide, one entry per text-bearing body, in deck order.

IReadOnlyList<string> ExtractText(byte[] pptx)

Parameters

pptx byte[]

Returns

IReadOnlyList<string>

Exceptions

ArgumentNullException

pptx is null.

ArgumentException

pptx is empty.

DocumentConversionException

The package could not be opened or read.

ExtractTextAsync(Stream, CancellationToken)

Reads a .pptx from source and returns all text found on every slide, in deck order. See ExtractText(byte[]) for exactly what counts as a text-bearing body. source is read to its end and is neither disposed, closed nor sought.

Task<IReadOnlyList<string>> ExtractTextAsync(Stream source, CancellationToken ct = default)

Parameters

source Stream
ct CancellationToken

Returns

Task<IReadOnlyList<string>>

Exceptions

ArgumentNullException

source is null.

ArgumentException

source is not readable or held no bytes.

OperationCanceledException

ct was cancelled.

DocumentConversionException

The package could not be opened or read.

ReplaceText(byte[], IReadOnlyDictionary<string, string>)

Replaces every key with its value across all slide text, returning updated bytes.

byte[] ReplaceText(byte[] pptx, IReadOnlyDictionary<string, string> replacements)

Parameters

pptx byte[]
replacements IReadOnlyDictionary<string, string>

Returns

byte[]

Exceptions

ArgumentNullException

Either argument is null.

ArgumentException

pptx is empty.

DocumentConversionException

The package could not be opened or edited.

ReplaceTextAsync(Stream, IReadOnlyDictionary<string, string>, Stream, CancellationToken)

Reads a .pptx from source, replaces every key with its value across all slide text, and writes the result to destination. See ReplaceText(byte[], IReadOnlyDictionary<string, string>) for exactly what counts as a match. source is read to its end and destination is written; neither is disposed, closed or sought.

Task ReplaceTextAsync(Stream source, IReadOnlyDictionary<string, string> replacements, Stream destination, CancellationToken ct = default)

Parameters

source Stream
replacements IReadOnlyDictionary<string, string>
destination Stream
ct CancellationToken

Returns

Task

Exceptions

ArgumentNullException

Any argument is null.

ArgumentException

source is not readable or held no bytes, or destination is not writable.

OperationCanceledException

ct was cancelled.

DocumentConversionException

The package could not be opened or edited.

SlideCount(byte[])

Number of slides in the deck, as counted from the deck's slide list.

int SlideCount(byte[] pptx)

Parameters

pptx byte[]

Returns

int

Exceptions

ArgumentNullException

pptx is null.

ArgumentException

pptx is empty.

DocumentConversionException

The package could not be opened or read.

SlideCountAsync(Stream, CancellationToken)

Reads a .pptx from source and returns its slide count, counted from the deck's slide list. source is read to its end and is neither disposed, closed nor sought.

Task<int> SlideCountAsync(Stream source, CancellationToken ct = default)

Parameters

source Stream
ct CancellationToken

Returns

Task<int>

Exceptions

ArgumentNullException

source is null.

ArgumentException

source is not readable or held no bytes.

OperationCanceledException

ct was cancelled.

DocumentConversionException

The package could not be opened or read.