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
slidesIEnumerable<PptxSlide>
Returns
- byte[]
Exceptions
- ArgumentNullException
slidesis null.- ArgumentException
An element of
slidesis 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
slidesIEnumerable<PptxSlide>destinationStreamctCancellationToken
Returns
Exceptions
- ArgumentNullException
slidesordestinationis null.- ArgumentException
An element of
slidesis null, ordestinationis not writable.- OperationCanceledException
ctwas 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
pptxbyte[]
Returns
Exceptions
- ArgumentNullException
pptxis null.- ArgumentException
pptxis 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
sourceStreamctCancellationToken
Returns
Exceptions
- ArgumentNullException
sourceis null.- ArgumentException
sourceis not readable or held no bytes.- OperationCanceledException
ctwas 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
pptxbyte[]replacementsIReadOnlyDictionary<string, string>
Returns
- byte[]
Exceptions
- ArgumentNullException
Either argument is null.
- ArgumentException
pptxis 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
sourceStreamreplacementsIReadOnlyDictionary<string, string>destinationStreamctCancellationToken
Returns
Exceptions
- ArgumentNullException
Any argument is null.
- ArgumentException
sourceis not readable or held no bytes, ordestinationis not writable.- OperationCanceledException
ctwas 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
pptxbyte[]
Returns
Exceptions
- ArgumentNullException
pptxis null.- ArgumentException
pptxis 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
sourceStreamctCancellationToken
Returns
Exceptions
- ArgumentNullException
sourceis null.- ArgumentException
sourceis not readable or held no bytes.- OperationCanceledException
ctwas cancelled.- DocumentConversionException
The package could not be opened or read.