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

AddChart(byte[], int, ChartType, ChartData, string, double, double, double, double)

Adds a chart to slide slideIndex and returns the updated presentation.

byte[] AddChart(byte[] pptx, int slideIndex, ChartType type, ChartData data, string title = "", double leftPoints = 0, double topPoints = 0, double widthPoints = 432, double heightPoints = 252)

Parameters

pptx byte[]

The presentation to add the chart to. It is not modified.

slideIndex int

1-based, because that is how a reader numbers slides.

type ChartType

The chart's shape.

data ChartData

The chart's categories and value series.

title string

The chart's title. Empty for no title.

leftPoints double

The chart's left edge, in points from the slide's left edge.

topPoints double

The chart's top edge, in points from the slide's top edge.

widthPoints double

The chart's width, in points.

heightPoints double

The chart's height, in points.

Returns

byte[]

Exceptions

ArgumentNullException

pptx or data is null.

ArgumentException

pptx is empty.

ArgumentOutOfRangeException

slideIndex is below 1, or above the deck's slide count.

DocumentConversionException

The package could not be opened or edited.

AddChartAsync(Stream, int, ChartType, ChartData, string, double, double, double, double, CancellationToken)

Reads a .pptx from source and returns a new presentation with a chart added to slide slideIndex — see AddChart(byte[], int, ChartType, ChartData, string, double, double, double, double) for the parameters. source is read to its end and is neither disposed, closed nor sought.

Task<byte[]> AddChartAsync(Stream source, int slideIndex, ChartType type, ChartData data, string title = "", double leftPoints = 0, double topPoints = 0, double widthPoints = 432, double heightPoints = 252, CancellationToken ct = default)

Parameters

source Stream
slideIndex int
type ChartType
data ChartData
title string
leftPoints double
topPoints double
widthPoints double
heightPoints double
ct CancellationToken

Returns

Task<byte[]>

Exceptions

ArgumentNullException

source or data is null.

ArgumentException

source is not readable or held no bytes.

ArgumentOutOfRangeException

slideIndex is below 1, or above the deck's slide count.

OperationCanceledException

ct was cancelled.

DocumentConversionException

The package could not be opened or edited.

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.

InsertSlides(byte[], int, IEnumerable<PptxSlide>)

A copy of pptx with slides inserted so that the first of them becomes slide atIndex. See Create(IEnumerable<PptxSlide>) for what a PptxSlide becomes.

byte[] InsertSlides(byte[] pptx, int atIndex, IEnumerable<PptxSlide> slides)

Parameters

pptx byte[]

The presentation to insert into. It is not modified.

atIndex int

1-based position the first inserted slide will occupy. SlideCount + 1 appends.

slides IEnumerable<PptxSlide>

The slides to insert, in order.

Returns

byte[]

Exceptions

ArgumentNullException

pptx or slides is null.

ArgumentException

pptx is empty, or an element of slides is null.

ArgumentOutOfRangeException

atIndex is below 1 or more than one past the last slide.

DocumentConversionException

The package could not be opened or edited, or the slide the new content would attach to has no layout of its own.

InsertSlidesAsync(Stream, int, IEnumerable<PptxSlide>, Stream, CancellationToken)

Reads a .pptx from source, inserts slides at atIndex, and writes the result to destination — see InsertSlides(byte[], int, IEnumerable<PptxSlide>) for the insertion and layout rules. Neither stream is disposed, closed or sought.

Task InsertSlidesAsync(Stream source, int atIndex, IEnumerable<PptxSlide> slides, Stream destination, CancellationToken ct = default)

Parameters

source Stream

The stream the .pptx package is read from.

atIndex int

1-based insertion position; SlideCount + 1 appends.

slides IEnumerable<PptxSlide>

The slides to insert, in order.

destination Stream

The stream the edited .pptx package is written to.

ct CancellationToken

Cancels the read, the edit and the write.

Returns

Task

Exceptions

ArgumentNullException

Any argument is null.

ArgumentException

source is not readable or held no bytes, destination is not writable, or an element of slides is null.

ArgumentOutOfRangeException

atIndex is below 1 or more than one past the last slide.

OperationCanceledException

ct was cancelled.

DocumentConversionException

The package could not be opened or edited, or the slide the new content would attach to has no layout of its own.

InspectSignatures(byte[])

Inspects pptx for digital signatures — whether it carries one, how many, and who claims to have signed it. Does not validate anything cryptographically; see ValidateSignatures(byte[], DocumentSignatureValidationOptions?).

DocumentSignatureInfo InspectSignatures(byte[] pptx)

Parameters

pptx byte[]

Returns

DocumentSignatureInfo

Exceptions

ArgumentNullException

pptx is null.

ArgumentException

pptx is empty.

DocumentConversionException

The presentation could not be inspected.

InspectSignaturesAsync(Stream, CancellationToken)

Reads a .pptx from source and inspects it for digital signatures — see InspectSignatures(byte[]). source is read to its end and is neither disposed, closed nor sought.

Task<DocumentSignatureInfo> InspectSignaturesAsync(Stream source, CancellationToken ct = default)

Parameters

source Stream
ct CancellationToken

Returns

Task<DocumentSignatureInfo>

Exceptions

ArgumentNullException

source is null.

ArgumentException

source is not readable or held no bytes.

OperationCanceledException

ct was cancelled.

DocumentConversionException

The presentation could not be inspected.

IsProtected(byte[])

Whether pptx is encrypted - that is, whether the other members here will refuse it. Reads the file signature; needs no password.

bool IsProtected(byte[] pptx)

Parameters

pptx byte[]

Returns

bool

Exceptions

ArgumentNullException

pptx is null.

IsProtectedAsync(Stream, CancellationToken)

Whether pptx is encrypted - that is, whether the other members here will refuse it. Reads the file signature; needs no password.

Task<bool> IsProtectedAsync(Stream source, CancellationToken ct = default)

Parameters

source Stream

The stream the presentation is read from.

ct CancellationToken

Cancels the read.

Returns

Task<bool>

Remarks

source is read to its end and is neither disposed, closed nor sought. Unlike IsProtected(byte[]), which answers false for an empty array, an empty source is rejected - every Stream overload in this package treats a source that held no bytes as a caller error rather than as content.

Exceptions

ArgumentNullException

source is null.

ArgumentException

source is not readable or held no bytes.

OperationCanceledException

ct was cancelled.

Protect(byte[], string)

A copy of pptx encrypted with password.

byte[] Protect(byte[] pptx, string password)

Parameters

pptx byte[]
password string

Returns

byte[]

Remarks

File encryption, not the "restrict editing" flag. The result is a compound file rather than a PPTX package, so every other member here refuses it - call Unprotect(byte[], string) first.

Exceptions

ArgumentNullException

pptx or password is null.

ArgumentException

pptx is empty, or password is empty.

DocumentConversionException

It could not be read or encrypted.

ProtectAsync(Stream, Stream, string, CancellationToken)

Reads a presentation from source and writes the encrypted copy to destination. Neither stream is disposed, closed or sought.

Task ProtectAsync(Stream source, Stream destination, string password, CancellationToken ct = default)

Parameters

source Stream
destination Stream
password string
ct CancellationToken

Returns

Task

Exceptions

ArgumentNullException

Either stream is null, or password is null.

ArgumentException

A stream is unusable, or password is empty.

OperationCanceledException

ct was cancelled.

DocumentConversionException

It could not be encrypted.

ReadMetadata(byte[])

The document properties pptx carries.

DocumentMetadata ReadMetadata(byte[] pptx)

Parameters

pptx byte[]

Returns

DocumentMetadata

Remarks

On a freshly created deck every property is null, exactly like DOCX and XLSX. That is not true after WithMetadata(byte[], DocumentMetadata); see its own remarks for why writing and reading disagree here.

Exceptions

ArgumentNullException

pptx is null.

ArgumentException

pptx is empty.

DocumentConversionException

The presentation could not be read.

ReadMetadataAsync(Stream, CancellationToken)

The document properties pptx carries.

Task<DocumentMetadata> ReadMetadataAsync(Stream source, CancellationToken ct = default)

Parameters

source Stream

The stream the presentation is read from.

ct CancellationToken

Cancels the read.

Returns

Task<DocumentMetadata>

Remarks

source is read to its end and is neither disposed, closed nor sought.

Exceptions

ArgumentNullException

source is null.

ArgumentException

source is not readable or held no bytes.

OperationCanceledException

ct was cancelled.

DocumentConversionException

The presentation could not be read.

ReadNotes(byte[], int)

The speaker notes on slide slideIndex, or an empty string when it has none. slideIndex is 1-based, like ReadSlide(byte[], int).

string ReadNotes(byte[] pptx, int slideIndex)

Parameters

pptx byte[]

The presentation to read.

slideIndex int

The 1-based slide number.

Returns

string

The notes text, or an empty string.

Remarks

A slide with no notes returns Empty, never null. Measured rather than assumed: every slide carries a notes object whose text is empty until something writes to it, so there is no "has notes" state to distinguish from "notes are blank" and the API does not invent one.

Notes are not returned by ExtractText(byte[]), which reads the slide bodies. They are a separate surface a reader has to ask for.

Exceptions

ArgumentNullException

pptx is null.

ArgumentException

pptx is empty.

ArgumentOutOfRangeException

slideIndex is below 1, or above the deck's slide count.

DocumentConversionException

The package could not be opened or read.

ReadNotesAsync(Stream, int, CancellationToken)

The speaker notes on slide slideIndex, or an empty string when it has none. slideIndex is 1-based, like ReadSlide(byte[], int).

Task<string> ReadNotesAsync(Stream source, int slideIndex, CancellationToken ct = default)

Parameters

source Stream

The stream the presentation is read from.

slideIndex int

The 1-based slide number.

ct CancellationToken

Cancels the read.

Returns

Task<string>

The notes text, or an empty string.

Remarks

source is read to its end and is neither disposed, closed nor sought.

Exceptions

ArgumentNullException

source is null.

ArgumentException

source is not readable or held no bytes.

ArgumentOutOfRangeException

slideIndex is below 1, or above the deck's slide count.

OperationCanceledException

ct was cancelled.

DocumentConversionException

The package could not be opened or read.

ReadSlide(byte[], int)

All text found on slide index. See ExtractText(byte[]) for exactly what counts as a text-bearing body.

IReadOnlyList<string> ReadSlide(byte[] pptx, int index)

Parameters

pptx byte[]

The presentation to read.

index int

1-based, because that is how a reader numbers slides.

Returns

IReadOnlyList<string>

Exceptions

ArgumentNullException

pptx is null.

ArgumentException

pptx is empty.

ArgumentOutOfRangeException

index is below 1, or above the deck's slide count.

DocumentConversionException

The package could not be opened or read.

ReadSlideAsync(Stream, int, CancellationToken)

Reads a .pptx from source and returns all text found on slide index — see ReadSlide(byte[], int). source is read to its end and is neither disposed, closed nor sought.

Task<IReadOnlyList<string>> ReadSlideAsync(Stream source, int index, CancellationToken ct = default)

Parameters

source Stream
index int
ct CancellationToken

Returns

Task<IReadOnlyList<string>>

Exceptions

ArgumentNullException

source is null.

ArgumentException

source is not readable or held no bytes.

ArgumentOutOfRangeException

index is below 1, or above the deck's slide count.

OperationCanceledException

ct was cancelled.

DocumentConversionException

The package could not be opened or read.

ReadSmartArt(byte[], int)

The text of every SmartArt diagram on slide index, one entry per diagram, each diagram's nodes joined with newlines in the order OfficeIMO reports them. An empty list means the slide has no SmartArt, which is not an error.

IReadOnlyList<string> ReadSmartArt(byte[] pptx, int index)

Parameters

pptx byte[]

The presentation to read.

index int

1-based, because that is how a reader numbers slides.

Returns

IReadOnlyList<string>

Exceptions

ArgumentNullException

pptx is null.

ArgumentException

pptx is empty.

ArgumentOutOfRangeException

index is below 1, or above the deck's slide count.

DocumentConversionException

The package could not be opened or read.

ReadSmartArtAsync(Stream, int, CancellationToken)

Reads a .pptx from source and returns the text of every SmartArt diagram on slide index — see ReadSmartArt(byte[], int). source is read to its end and is neither disposed, closed nor sought.

Task<IReadOnlyList<string>> ReadSmartArtAsync(Stream source, int index, CancellationToken ct = default)

Parameters

source Stream
index int
ct CancellationToken

Returns

Task<IReadOnlyList<string>>

Exceptions

ArgumentNullException

source is null.

ArgumentException

source is not readable or held no bytes.

ArgumentOutOfRangeException

index is below 1, or above the deck's slide count.

OperationCanceledException

ct was cancelled.

DocumentConversionException

The package could not be opened or read.

RemoveSlides(byte[], IEnumerable<int>)

A copy of pptx with the slides at indices removed.

byte[] RemoveSlides(byte[] pptx, IEnumerable<int> indices)

Parameters

pptx byte[]

The presentation to remove slides from. It is not modified.

indices IEnumerable<int>

1-based slide numbers to remove, each exactly once and in any order — not a contiguous range.

Returns

byte[]

Exceptions

ArgumentNullException

pptx or indices is null.

ArgumentException

pptx is empty, or indices contains a duplicate.

ArgumentOutOfRangeException

An index in indices is outside the deck's slide range, or removing every listed index would leave a zero-slide deck.

DocumentConversionException

The package could not be opened or edited.

RemoveSlidesAsync(Stream, IEnumerable<int>, Stream, CancellationToken)

Reads a .pptx from source, removes the slides at indices, and writes the result to destination — see RemoveSlides(byte[], IEnumerable<int>). Neither stream is disposed, closed or sought.

Task RemoveSlidesAsync(Stream source, IEnumerable<int> indices, Stream destination, CancellationToken ct = default)

Parameters

source Stream

The stream the .pptx package is read from.

indices IEnumerable<int>

1-based slide numbers to remove, each exactly once, any order.

destination Stream

The stream the edited .pptx package is written to.

ct CancellationToken

Cancels the read, the edit and the write.

Returns

Task

Exceptions

ArgumentNullException

Any argument is null.

ArgumentException

source is not readable or held no bytes, destination is not writable, or indices contains a duplicate.

ArgumentOutOfRangeException

An index in indices is outside the deck's slide range, or removing every listed index would leave a zero-slide deck.

OperationCanceledException

ct was cancelled.

DocumentConversionException

The package could not be opened or edited.

ReorderSlides(byte[], IEnumerable<int>)

A copy of pptx with its slides in the order given by order, which holds 1-based slide numbers.

byte[] ReorderSlides(byte[] pptx, IEnumerable<int> order)

Parameters

pptx byte[]

The presentation to reorder. It is not modified.

order IEnumerable<int>

A permutation of every slide — the same slides, in a different order.

Returns

byte[]

Exceptions

ArgumentNullException

pptx or order is null.

ArgumentException

pptx is empty, or order is not a permutation of 1..SlideCount.

DocumentConversionException

The package could not be opened or edited.

ReorderSlidesAsync(Stream, IEnumerable<int>, Stream, CancellationToken)

Reads a .pptx from source, reorders its slides per order, and writes the result to destination — see ReorderSlides(byte[], IEnumerable<int>). Neither stream is disposed, closed or sought.

Task ReorderSlidesAsync(Stream source, IEnumerable<int> order, Stream destination, CancellationToken ct = default)

Parameters

source Stream

The stream the .pptx package is read from.

order IEnumerable<int>

A permutation of every slide's 1-based number.

destination Stream

The stream the edited .pptx package is written to.

ct CancellationToken

Cancels the read, the edit and the write.

Returns

Task

Exceptions

ArgumentNullException

Any argument is null.

ArgumentException

source is not readable or held no bytes, destination is not writable, or order is not a permutation of every slide.

OperationCanceledException

ct was cancelled.

DocumentConversionException

The package could not be opened or edited.

ReplaceImage(byte[], string, byte[])

Replaces every shape whose text is exactly placeholder with image, scaled to fit inside that shape's box and centred there. Position and size come from the template, so there is nothing to pass — a designer draws a box in PowerPoint where the image belongs and the image lands there. The shape's text must be nothing but the placeholder; PNG and JPEG only, detected from magic bytes rather than any filename.

byte[] ReplaceImage(byte[] pptx, string placeholder, byte[] image)

Parameters

pptx byte[]
placeholder string
image byte[]

Returns

byte[]

Exceptions

ArgumentNullException

Any argument is null.

ArgumentException

pptx or image is empty, or placeholder is blank.

DocumentConversionException

The placeholder appears nowhere, appears only inside a grouped shape, a matched shape holds other text, a matched shape has no explicit position, the image is neither PNG nor JPEG, or the package could not be edited.

ReplaceImageAsync(Stream, string, byte[], Stream, CancellationToken)

Reads a .pptx from source, replaces every shape whose text is exactly placeholder with image, and writes the result to destination. See ReplaceImage(byte[], string, byte[]) for exactly what counts as a match. source is read to its end and destination is written; neither is disposed, closed or sought.

Task ReplaceImageAsync(Stream source, string placeholder, byte[] image, Stream destination, CancellationToken ct = default)

Parameters

source Stream
placeholder string
image byte[]
destination Stream
ct CancellationToken

Returns

Task

Exceptions

ArgumentNullException

Any argument is null.

ArgumentException

placeholder is blank, image is empty, source is not readable or held no bytes, or destination is not writable.

OperationCanceledException

ct was cancelled.

DocumentConversionException

The placeholder appears nowhere, appears only inside a grouped shape, a matched shape holds other text, a matched shape has no explicit position, the image is neither PNG nor JPEG, or the package could not be edited.

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.

SetNotes(byte[], int, string)

Sets the speaker notes on slide slideIndex and returns the updated deck. slideIndex is 1-based, like ReadSlide(byte[], int).

byte[] SetNotes(byte[] pptx, int slideIndex, string notes)

Parameters

pptx byte[]

The presentation to edit. It is not modified.

slideIndex int

The 1-based slide number.

notes string

The notes text. Empty clears them.

Returns

byte[]

A new presentation; the input is not modified.

Remarks

Replaces whatever the slide's notes said; pass an empty string to clear them. Every other slide is left exactly as it was — measured, because editing one slide's notes and silently disturbing another's is the kind of loss no text-reading test would notice.

Exceptions

ArgumentNullException

pptx or notes is null.

ArgumentException

pptx is empty.

ArgumentOutOfRangeException

slideIndex is below 1, or above the deck's slide count.

DocumentConversionException

The package could not be opened or written.

SetNotesAsync(Stream, int, string, Stream, CancellationToken)

Sets the speaker notes on slide slideIndex and returns the updated deck. slideIndex is 1-based, like ReadSlide(byte[], int).

Task SetNotesAsync(Stream source, int slideIndex, string notes, Stream destination, CancellationToken ct = default)

Parameters

source Stream

The stream the presentation is read from.

slideIndex int

The 1-based slide number.

notes string

The notes text. Empty clears them.

destination Stream

The stream the updated deck is written to.

ct CancellationToken

Cancels the read, the edit and the write.

Returns

Task

Remarks

source is read to its end and destination is written; neither is disposed, closed or sought, and neither has to be seekable.

Exceptions

ArgumentNullException

An argument is null.

ArgumentException

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

ArgumentOutOfRangeException

slideIndex is below 1, or above the deck's slide count.

OperationCanceledException

ct was cancelled.

DocumentConversionException

The package could not be opened or written.

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.

Unprotect(byte[], string)

A copy of pptx with its encryption removed.

byte[] Unprotect(byte[] pptx, string password)

Parameters

pptx byte[]
password string

Returns

byte[]

Exceptions

ArgumentNullException

pptx or password is null.

ArgumentException

pptx is empty, or password is empty.

DocumentConversionException

The password was wrong, the presentation was not encrypted, or it could not be read.

UnprotectAsync(Stream, Stream, string, CancellationToken)

Reads an encrypted presentation from source and writes the unprotected copy to destination. Neither stream is disposed, closed or sought.

Task UnprotectAsync(Stream source, Stream destination, string password, CancellationToken ct = default)

Parameters

source Stream
destination Stream
password string
ct CancellationToken

Returns

Task

Exceptions

ArgumentNullException

Either stream is null, or password is null.

ArgumentException

A stream is unusable, or password is empty.

OperationCanceledException

ct was cancelled.

DocumentConversionException

The password was wrong, or it could not be read.

ValidateSignatures(byte[], DocumentSignatureValidationOptions?)

Validates every digital signature pptx carries, returning the report-level tamper-detection verdict alongside each signature's own certificate chain trust and revocation status. Never performs revocation checking or certificate downloads over the network, regardless of options — see DocumentSignatureValidationOptions's own remarks.

DocumentSignatureValidationReport ValidateSignatures(byte[] pptx, DocumentSignatureValidationOptions? options = null)

Parameters

pptx byte[]
options DocumentSignatureValidationOptions

Returns

DocumentSignatureValidationReport

Exceptions

ArgumentNullException

pptx is null.

ArgumentException

pptx is empty.

DocumentConversionException

The presentation could not be validated.

ValidateSignaturesAsync(Stream, DocumentSignatureValidationOptions?, CancellationToken)

Reads a .pptx from source and validates its digital signatures — see ValidateSignatures(byte[], DocumentSignatureValidationOptions?). source is read to its end and is neither disposed, closed nor sought.

Task<DocumentSignatureValidationReport> ValidateSignaturesAsync(Stream source, DocumentSignatureValidationOptions? options = null, CancellationToken ct = default)

Parameters

source Stream
options DocumentSignatureValidationOptions
ct CancellationToken

Returns

Task<DocumentSignatureValidationReport>

Exceptions

ArgumentNullException

source is null.

ArgumentException

source is not readable or held no bytes.

OperationCanceledException

ct was cancelled.

DocumentConversionException

The presentation could not be validated.

WithMetadata(byte[], DocumentMetadata)

A copy of pptx carrying metadata.

byte[] WithMetadata(byte[] pptx, DocumentMetadata metadata)

Parameters

pptx byte[]
metadata DocumentMetadata

Returns

byte[]

Remarks

A null property leaves what the presentation already had in place, so stamping a title does not silently erase an author. Pass an empty string to clear one.

One exception, forced by OfficeIMO itself: Creator never survives as null through this method. OfficeIMO.PowerPoint's own Save() unconditionally stamps Creator to "OfficeIMO" whenever it is empty at save time. ReadMetadata(byte[]) alone, with no save involved, correctly reports null on an untouched deck; it is specifically going through this method — which always saves — that loses the distinction. DOCX and XLSX do not have this behaviour.

Exceptions

ArgumentNullException

pptx or metadata is null.

ArgumentException

pptx is empty.

DocumentConversionException

The presentation could not be read or written.

WithMetadataAsync(Stream, DocumentMetadata, Stream, CancellationToken)

A copy of pptx carrying metadata.

Task WithMetadataAsync(Stream source, DocumentMetadata metadata, Stream destination, CancellationToken ct = default)

Parameters

source Stream

The stream the presentation is read from.

metadata DocumentMetadata

The properties to stamp.

destination Stream

The stream the updated presentation is written to.

ct CancellationToken

Cancels the read, the edit and the write.

Returns

Task

Remarks

source is read to its end and destination is written; neither is disposed, closed or sought, and neither has to be seekable.

Exceptions

ArgumentNullException

An argument is null.

ArgumentException

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

OperationCanceledException

ct was cancelled.

DocumentConversionException

The presentation could not be read or written.