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
pptxbyte[]The presentation to add the chart to. It is not modified.
slideIndexint1-based, because that is how a reader numbers slides.
typeChartTypeThe chart's shape.
dataChartDataThe chart's categories and value series.
titlestringThe chart's title. Empty for no title.
leftPointsdoubleThe chart's left edge, in points from the slide's left edge.
topPointsdoubleThe chart's top edge, in points from the slide's top edge.
widthPointsdoubleThe chart's width, in points.
heightPointsdoubleThe chart's height, in points.
Returns
- byte[]
Exceptions
- ArgumentNullException
pptxordatais null.- ArgumentException
pptxis empty.- ArgumentOutOfRangeException
slideIndexis 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
sourceStreamslideIndexinttypeChartTypedataChartDatatitlestringleftPointsdoubletopPointsdoublewidthPointsdoubleheightPointsdoublectCancellationToken
Returns
Exceptions
- ArgumentNullException
sourceordatais null.- ArgumentException
sourceis not readable or held no bytes.- ArgumentOutOfRangeException
slideIndexis below 1, or above the deck's slide count.- OperationCanceledException
ctwas 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
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.
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
pptxbyte[]The presentation to insert into. It is not modified.
atIndexint1-based position the first inserted slide will occupy.
SlideCount + 1appends.slidesIEnumerable<PptxSlide>The slides to insert, in order.
Returns
- byte[]
Exceptions
- ArgumentNullException
pptxorslidesis null.- ArgumentException
pptxis empty, or an element ofslidesis null.- ArgumentOutOfRangeException
atIndexis 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
sourceStreamThe stream the .pptx package is read from.
atIndexint1-based insertion position;
SlideCount + 1appends.slidesIEnumerable<PptxSlide>The slides to insert, in order.
destinationStreamThe stream the edited .pptx package is written to.
ctCancellationTokenCancels the read, the edit and the write.
Returns
Exceptions
- ArgumentNullException
Any argument is null.
- ArgumentException
sourceis not readable or held no bytes,destinationis not writable, or an element ofslidesis null.- ArgumentOutOfRangeException
atIndexis below 1 or more than one past the last slide.- OperationCanceledException
ctwas 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
pptxbyte[]
Returns
Exceptions
- ArgumentNullException
pptxis null.- ArgumentException
pptxis 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
sourceStreamctCancellationToken
Returns
Exceptions
- ArgumentNullException
sourceis null.- ArgumentException
sourceis not readable or held no bytes.- OperationCanceledException
ctwas 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
pptxbyte[]
Returns
Exceptions
- ArgumentNullException
pptxis 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
sourceStreamThe stream the presentation is read from.
ctCancellationTokenCancels the read.
Returns
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
sourceis null.- ArgumentException
sourceis not readable or held no bytes.- OperationCanceledException
ctwas cancelled.
Protect(byte[], string)
A copy of pptx encrypted with password.
byte[] Protect(byte[] pptx, string password)
Parameters
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
pptxorpasswordis null.- ArgumentException
pptxis empty, orpasswordis 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
sourceStreamdestinationStreampasswordstringctCancellationToken
Returns
Exceptions
- ArgumentNullException
Either stream is null, or
passwordis null.- ArgumentException
A stream is unusable, or
passwordis empty.- OperationCanceledException
ctwas cancelled.- DocumentConversionException
It could not be encrypted.
ReadMetadata(byte[])
The document properties pptx carries.
DocumentMetadata ReadMetadata(byte[] pptx)
Parameters
pptxbyte[]
Returns
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
pptxis null.- ArgumentException
pptxis 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
sourceStreamThe stream the presentation is read from.
ctCancellationTokenCancels the read.
Returns
Remarks
source is read to its end and is neither disposed, closed nor sought.
Exceptions
- ArgumentNullException
sourceis null.- ArgumentException
sourceis not readable or held no bytes.- OperationCanceledException
ctwas 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
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
pptxis null.- ArgumentException
pptxis empty.- ArgumentOutOfRangeException
slideIndexis 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
sourceStreamThe stream the presentation is read from.
slideIndexintThe 1-based slide number.
ctCancellationTokenCancels the read.
Returns
Remarks
source is read to its end and is neither disposed, closed nor sought.
Exceptions
- ArgumentNullException
sourceis null.- ArgumentException
sourceis not readable or held no bytes.- ArgumentOutOfRangeException
slideIndexis below 1, or above the deck's slide count.- OperationCanceledException
ctwas 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
pptxbyte[]The presentation to read.
indexint1-based, because that is how a reader numbers slides.
Returns
Exceptions
- ArgumentNullException
pptxis null.- ArgumentException
pptxis empty.- ArgumentOutOfRangeException
indexis 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
sourceStreamindexintctCancellationToken
Returns
Exceptions
- ArgumentNullException
sourceis null.- ArgumentException
sourceis not readable or held no bytes.- ArgumentOutOfRangeException
indexis below 1, or above the deck's slide count.- OperationCanceledException
ctwas 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
pptxbyte[]The presentation to read.
indexint1-based, because that is how a reader numbers slides.
Returns
Exceptions
- ArgumentNullException
pptxis null.- ArgumentException
pptxis empty.- ArgumentOutOfRangeException
indexis 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
sourceStreamindexintctCancellationToken
Returns
Exceptions
- ArgumentNullException
sourceis null.- ArgumentException
sourceis not readable or held no bytes.- ArgumentOutOfRangeException
indexis below 1, or above the deck's slide count.- OperationCanceledException
ctwas 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
pptxbyte[]The presentation to remove slides from. It is not modified.
indicesIEnumerable<int>1-based slide numbers to remove, each exactly once and in any order — not a contiguous range.
Returns
- byte[]
Exceptions
- ArgumentNullException
pptxorindicesis null.- ArgumentException
pptxis empty, orindicescontains a duplicate.- ArgumentOutOfRangeException
An index in
indicesis 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
sourceStreamThe stream the .pptx package is read from.
indicesIEnumerable<int>1-based slide numbers to remove, each exactly once, any order.
destinationStreamThe stream the edited .pptx package is written to.
ctCancellationTokenCancels the read, the edit and the write.
Returns
Exceptions
- ArgumentNullException
Any argument is null.
- ArgumentException
sourceis not readable or held no bytes,destinationis not writable, orindicescontains a duplicate.- ArgumentOutOfRangeException
An index in
indicesis outside the deck's slide range, or removing every listed index would leave a zero-slide deck.- OperationCanceledException
ctwas 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
pptxbyte[]The presentation to reorder. It is not modified.
orderIEnumerable<int>A permutation of every slide — the same slides, in a different order.
Returns
- byte[]
Exceptions
- ArgumentNullException
pptxororderis null.- ArgumentException
pptxis empty, ororderis 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
sourceStreamThe stream the .pptx package is read from.
orderIEnumerable<int>A permutation of every slide's 1-based number.
destinationStreamThe stream the edited .pptx package is written to.
ctCancellationTokenCancels the read, the edit and the write.
Returns
Exceptions
- ArgumentNullException
Any argument is null.
- ArgumentException
sourceis not readable or held no bytes,destinationis not writable, ororderis not a permutation of every slide.- OperationCanceledException
ctwas 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
Returns
- byte[]
Exceptions
- ArgumentNullException
Any argument is null.
- ArgumentException
pptxorimageis empty, orplaceholderis 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
sourceStreamplaceholderstringimagebyte[]destinationStreamctCancellationToken
Returns
Exceptions
- ArgumentNullException
Any argument is null.
- ArgumentException
placeholderis blank,imageis empty,sourceis not readable or held no bytes, ordestinationis not writable.- OperationCanceledException
ctwas 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
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.
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
pptxbyte[]The presentation to edit. It is not modified.
slideIndexintThe 1-based slide number.
notesstringThe 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
pptxornotesis null.- ArgumentException
pptxis empty.- ArgumentOutOfRangeException
slideIndexis 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
sourceStreamThe stream the presentation is read from.
slideIndexintThe 1-based slide number.
notesstringThe notes text. Empty clears them.
destinationStreamThe stream the updated deck is written to.
ctCancellationTokenCancels the read, the edit and the write.
Returns
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
sourceis not readable or held no bytes, ordestinationis not writable.- ArgumentOutOfRangeException
slideIndexis below 1, or above the deck's slide count.- OperationCanceledException
ctwas 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
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.
Unprotect(byte[], string)
A copy of pptx with its encryption removed.
byte[] Unprotect(byte[] pptx, string password)
Parameters
Returns
- byte[]
Exceptions
- ArgumentNullException
pptxorpasswordis null.- ArgumentException
pptxis empty, orpasswordis 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
sourceStreamdestinationStreampasswordstringctCancellationToken
Returns
Exceptions
- ArgumentNullException
Either stream is null, or
passwordis null.- ArgumentException
A stream is unusable, or
passwordis empty.- OperationCanceledException
ctwas 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
pptxbyte[]optionsDocumentSignatureValidationOptions
Returns
Exceptions
- ArgumentNullException
pptxis null.- ArgumentException
pptxis 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
sourceStreamoptionsDocumentSignatureValidationOptionsctCancellationToken
Returns
Exceptions
- ArgumentNullException
sourceis null.- ArgumentException
sourceis not readable or held no bytes.- OperationCanceledException
ctwas cancelled.- DocumentConversionException
The presentation could not be validated.
WithMetadata(byte[], DocumentMetadata)
A copy of pptx carrying metadata.
byte[] WithMetadata(byte[] pptx, DocumentMetadata metadata)
Parameters
pptxbyte[]metadataDocumentMetadata
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
pptxormetadatais null.- ArgumentException
pptxis 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
sourceStreamThe stream the presentation is read from.
metadataDocumentMetadataThe properties to stamp.
destinationStreamThe stream the updated presentation is written to.
ctCancellationTokenCancels the read, the edit and the write.
Returns
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
sourceis not readable or held no bytes, ordestinationis not writable.- OperationCanceledException
ctwas cancelled.- DocumentConversionException
The presentation could not be read or written.