Class Presentation
Represents the presentation used by the presentation model.
Implements
Inherited Members
Namespace: DRIT.Presentation
Assembly: DRIT.Presentation.dll
Syntax
public class Presentation : IDisposable
Constructors
Presentation()
Initializes a new instance of the presentation class.
Declaration
public Presentation()
Presentation(PresentationMode, string)
Creates a new presentation using the specified creation mode and language.
Declaration
public Presentation(PresentationMode creationMode, string language = "en-US")
Parameters
| Type | Name | Description |
|---|---|---|
| PresentationMode | creationMode | The output and default-content creation mode. |
| string | language | The language used for generated text and field content. |
Presentation(Stream, FormatType)
Initializes a new instance of the presentation class.
Declaration
public Presentation(Stream stream, FormatType formatType)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | The stream supplied to this operation. |
| FormatType | formatType | The format type supplied to this operation. |
Presentation(Stream, FormatType, PresentationMode, string)
Opens a presentation from a stream and selects the output serialization mode.
Declaration
public Presentation(Stream stream, FormatType formatType, PresentationMode creationMode, string language = "en-US")
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | Stream containing the source presentation. |
| FormatType | formatType | Format of the source presentation. |
| PresentationMode | creationMode | Mode used when the presentation is subsequently saved. |
| string | language | Language used for generated text and field content. |
Presentation(Stream, FormatType, string)
Opens a presentation from stream using the specified password.
Declaration
public Presentation(Stream stream, FormatType formatType, string password)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | |
| FormatType | formatType | |
| string | password |
Presentation(string, FormatType)
Initializes a new instance of the presentation class.
Declaration
public Presentation(string path, FormatType formatType)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The path supplied to this operation. |
| FormatType | formatType | The format type supplied to this operation. |
Presentation(string, FormatType, PresentationMode, string)
Opens a presentation from disk and selects the output serialization mode.
Declaration
public Presentation(string path, FormatType formatType, PresentationMode creationMode, string language = "en-US")
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | Path to the source presentation. |
| FormatType | formatType | Format of the source presentation. |
| PresentationMode | creationMode | Mode used when the presentation is subsequently saved. |
| string | language | Language used for generated text and field content. |
Presentation(string, FormatType, string)
Opens a presentation from disk using the specified password.
Declaration
public Presentation(string path, FormatType formatType, string password)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | |
| FormatType | formatType | |
| string | password |
Properties
BinaryChartImportReport
Diagnostics generated during binary .ppt chart probing. Populated by the binary reader; null for Open XML loads.
Declaration
public BinaryChartImportReport BinaryChartImportReport { get; }
Property Value
| Type | Description |
|---|---|
| BinaryChartImportReport |
BinaryParserDiagnostics
Diagnostics generated while reading binary .ppt record streams. Populated by the binary reader for binary import workflows.
Declaration
public BinaryParserDiagnostics BinaryParserDiagnostics { get; }
Property Value
| Type | Description |
|---|---|
| BinaryParserDiagnostics |
BinaryPreservedFragments
Gets the collection of binary preserved fragments associated with this object.
Declaration
public IReadOnlyList<PreservedFragment> BinaryPreservedFragments { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<PreservedFragment> |
ConversionDiagnostics
Stable read-only conversion diagnostics from the most recent cross-format save. Use this property instead of the legacy ConversionIssues property.
Declaration
public ConversionIssueCollection ConversionDiagnostics { get; }
Property Value
| Type | Description |
|---|---|
| ConversionIssueCollection |
ConversionIssues
Issues collected during the most recent cross-format save operation.
Populated when the write target format differs from the load source format.
null when no cross-format save has occurred yet, or when the source
and target formats are the same.
Declaration
public ConversionIssueCollection ConversionIssues { get; }
Property Value
| Type | Description |
|---|---|
| ConversionIssueCollection |
CustomShows
The custom slide shows defined for this presentation.
Declaration
public CustomShowCollection CustomShows { get; }
Property Value
| Type | Description |
|---|---|
| CustomShowCollection |
CustomXmlParts
The custom XML parts embedded in this presentation package. An empty collection indicates no custom XML parts are present.
Declaration
public CustomXmlPartCollection CustomXmlParts { get; }
Property Value
| Type | Description |
|---|---|
| CustomXmlPartCollection |
FontsManager
Gets the font manager for this presentation, providing access to embedded fonts, font substitution rules, and font fallback rules.
Declaration
public FontsManager FontsManager { get; }
Property Value
| Type | Description |
|---|---|
| FontsManager |
HandoutMaster
Gets or sets the handout master associated with this object.
Declaration
public Slide HandoutMaster { get; }
Property Value
| Type | Description |
|---|---|
| Slide |
HasPresentationProperties
Gets or sets whether has presentation properties is enabled.
Declaration
public bool HasPresentationProperties { get; }
Property Value
| Type | Description |
|---|---|
| bool |
HasTableStyles
Gets or sets whether has table styles is enabled.
Declaration
public bool HasTableStyles { get; }
Property Value
| Type | Description |
|---|---|
| bool |
HasViewProperties
Gets or sets whether has view properties is enabled.
Declaration
public bool HasViewProperties { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsWriteProtected
Gets whether the presentation currently carries write-protection metadata.
Declaration
public bool IsWriteProtected { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Language
Gets or sets the language used for generated text, field content, and localized PowerPoint 16 template content.
Declaration
public string Language { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Remarks
Set this property after construction when the language is determined at
runtime. It must be set before saving for the value to affect generated
content. The default language is en-US.
ModifyProtection
Gets the modify-protection settings for this presentation. When a modify password is set, the presentation can be opened read-only without the password, but modifications require the password.
Declaration
public ModifyProtection ModifyProtection { get; }
Property Value
| Type | Description |
|---|---|
| ModifyProtection |
NotesMaster
Gets or sets the notes master associated with this object.
Declaration
public Slide NotesMaster { get; }
Property Value
| Type | Description |
|---|---|
| Slide |
OdfConversionDiagnostics
Diagnostics produced during the most recent ODP open operation.
null when the presentation was not loaded from an ODP file.
Declaration
public OdfConversionDiagnostics OdfConversionDiagnostics { get; }
Property Value
| Type | Description |
|---|---|
| OdfConversionDiagnostics |
PresentationSettings
Gets or sets the presentation settings associated with this object.
Declaration
public PresentationPropertiesInfo PresentationSettings { get; }
Property Value
| Type | Description |
|---|---|
| PresentationPropertiesInfo |
Properties
Gets or sets the properties associated with this object.
Declaration
public DocumentProperties Properties { get; }
Property Value
| Type | Description |
|---|---|
| DocumentProperties |
Sections
The named sections that group slides in this presentation. An empty collection indicates no sections are defined.
Declaration
public SectionCollection Sections { get; }
Property Value
| Type | Description |
|---|---|
| SectionCollection |
SensitivityLabels
Gets the collection of sensitivity labels associated with this object.
Declaration
public SensitivityLabelCollection SensitivityLabels { get; }
Property Value
| Type | Description |
|---|---|
| SensitivityLabelCollection |
SlideLayoutSettings
Gets or sets the slide layout settings associated with this object.
Declaration
public SlideLayoutInfo SlideLayoutSettings { get; }
Property Value
| Type | Description |
|---|---|
| SlideLayoutInfo |
SlideMaster
Gets or sets the slide master associated with this object.
Declaration
public SlideMaster SlideMaster { get; }
Property Value
| Type | Description |
|---|---|
| SlideMaster |
SlideMasterSettings
Gets or sets the slide master settings associated with this object.
Declaration
public SlideMasterInfo SlideMasterSettings { get; }
Property Value
| Type | Description |
|---|---|
| SlideMasterInfo |
SlideMasters
Handles slide master collection for this presentation.
Declaration
public SlideMasterCollection SlideMasters { get; }
Property Value
| Type | Description |
|---|---|
| SlideMasterCollection |
SlideSize
Gets or sets the slide size associated with this object.
Declaration
public SlideSize SlideSize { get; }
Property Value
| Type | Description |
|---|---|
| SlideSize |
Slides
Gets the collection of slides associated with this object.
Declaration
public SlideCollection Slides { get; }
Property Value
| Type | Description |
|---|---|
| SlideCollection |
TableStyleSettings
Gets or sets the table style settings associated with this object.
Declaration
public TableStylesInfo TableStyleSettings { get; }
Property Value
| Type | Description |
|---|---|
| TableStylesInfo |
TableStyles
Gets the collection of table styles defined in this presentation.
Read-first: styles are populated from the OOXML tblStyleLst
on first access. Use FindById(Guid)
to look up a style by its GUID.
Declaration
public TableStyleCollection TableStyles { get; }
Property Value
| Type | Description |
|---|---|
| TableStyleCollection |
Theme
Gets or sets the theme associated with this object.
Declaration
public Theme Theme { get; }
Property Value
| Type | Description |
|---|---|
| Theme |
ThemeResolutionDiagnostics
Theme values that could not be resolved from the active slide master during conversion or export.
Declaration
public ThemeResolutionDiagnostics ThemeResolutionDiagnostics { get; }
Property Value
| Type | Description |
|---|---|
| ThemeResolutionDiagnostics |
ThemeSettings
Gets or sets the theme settings associated with this object.
Declaration
public ThemeInfo ThemeSettings { get; }
Property Value
| Type | Description |
|---|---|
| ThemeInfo |
VbaProject
Gets or sets the vba project associated with this object.
Declaration
public Project VbaProject { get; }
Property Value
| Type | Description |
|---|---|
| Project |
ViewSettings
Gets or sets the view settings associated with this object.
Declaration
public ViewPropertiesInfo ViewSettings { get; }
Property Value
| Type | Description |
|---|---|
| ViewPropertiesInfo |
Methods
AddClone(Slide)
Deep-clones source and appends the clone to the end of
Slides. All shapes, text, formatting, and intra-package media
references are preserved. The source slide must already
belong to a presentation (i.e. it was returned by AddSlide() or
loaded from a file).
For same-presentation cloning all media parts (images, audio, video) are shared automatically. For cross-presentation cloning, use the overload that accepts a CloneContext when the source slide contains internal slide links.
Declaration
public Slide AddClone(Slide source)
Parameters
| Type | Name | Description |
|---|---|---|
| Slide | source | The slide to clone. |
Returns
| Type | Description |
|---|---|
| Slide | The newly appended clone slide. |
AddClone(Slide, CloneContext)
Deep-clones source and appends the clone to the end of
Slides, using context to remap internal
slide hyperlinks when the source belongs to another presentation.
Declaration
public Slide AddClone(Slide source, CloneContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| Slide | source | The slide to clone. |
| CloneContext | context | The source-to-destination clone context. |
Returns
| Type | Description |
|---|---|
| Slide | The newly appended clone slide. |
AddSlide()
Appends a new empty slide to the end of Slides and returns it.
Declaration
public Slide AddSlide()
Returns
| Type | Description |
|---|---|
| Slide |
AddSlide(SlideLayoutType)
Appends a new slide based on the first LayoutSlide whose type
matches layoutType (searched across all slide masters).
Falls back to the first available layout when no match is found.
Declaration
public Slide AddSlide(SlideLayoutType layoutType)
Parameters
| Type | Name | Description |
|---|---|---|
| SlideLayoutType | layoutType |
Returns
| Type | Description |
|---|---|
| Slide |
AddSlide(LayoutSlide)
Appends a new slide based on the specified layout
and returns it. The new slide's package relationship is wired to the
layout part identified by layout.
Falls back to the default layout when layout is null.
Declaration
public Slide AddSlide(LayoutSlide layout)
Parameters
| Type | Name | Description |
|---|---|---|
| LayoutSlide | layout |
Returns
| Type | Description |
|---|---|
| Slide |
AppendDigitalSignature(string, PptxDigitalSignatureSaveOptions)
Appends a single digital signature to an existing unencrypted PPTX package.
Declaration
public static void AppendDigitalSignature(string path, PptxDigitalSignatureSaveOptions signature)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | |
| PptxDigitalSignatureSaveOptions | signature |
AppendDigitalSignatures(string, IEnumerable<PptxDigitalSignatureSaveOptions>)
Appends multiple digital signatures to an existing unencrypted PPTX package.
Declaration
public static void AppendDigitalSignatures(string path, IEnumerable<PptxDigitalSignatureSaveOptions> signatures)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | |
| IEnumerable<PptxDigitalSignatureSaveOptions> | signatures |
Dispose()
Releases file handles and resources held by the presentation.
Declaration
public void Dispose()
FindAll(string, StringComparison)
Finds all matches across all slides.
Declaration
public IReadOnlyList<SlideTextMatch> FindAll(string searchText, StringComparison comparison = StringComparison.Ordinal)
Parameters
| Type | Name | Description |
|---|---|---|
| string | searchText | |
| StringComparison | comparison |
Returns
| Type | Description |
|---|---|
| IReadOnlyList<SlideTextMatch> |
GetBinaryChartImportTraceEntries()
Returns flattened chart probe trace entries across all slides.
Declaration
public IList<BinaryChartImportTraceEntry> GetBinaryChartImportTraceEntries()
Returns
| Type | Description |
|---|---|
| IList<BinaryChartImportTraceEntry> |
ListDigitalSignatures(string)
Lists digital signatures in an existing unencrypted PPTX package.
Declaration
public static IList<PptxDigitalSignatureInfo> ListDigitalSignatures(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path |
Returns
| Type | Description |
|---|---|
| IList<PptxDigitalSignatureInfo> |
Load(string)
Loads a presentation from disk by inferring the format from file extension.
Declaration
public static Presentation Load(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | Path to the source presentation file. |
Returns
| Type | Description |
|---|---|
| Presentation | A loaded Presentation instance. |
Load(string, LoadOptions)
Loads a presentation from disk using the specified LoadOptions. The options type determines the load behavior:
- PptxLoadOptions — PPTX format with encryption support.
Declaration
public static Presentation Load(string path, LoadOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | Path to the source presentation file. |
| LoadOptions | options | The load options. Must not be null. |
Returns
| Type | Description |
|---|---|
| Presentation | A loaded Presentation instance. |
Load(string, PptxLoadOptions)
Loads a presentation from disk by inferring format from file extension and applying PPTX load options.
Declaration
public static Presentation Load(string path, PptxLoadOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | |
| PptxLoadOptions | options |
Returns
| Type | Description |
|---|---|
| Presentation |
Load(string, string)
Loads a password-protected presentation from disk by inferring format from file extension.
Declaration
public static Presentation Load(string path, string password)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | |
| string | password |
Returns
| Type | Description |
|---|---|
| Presentation |
RemoveDigitalSignatures(string)
Removes all digital signatures from an existing unencrypted PPTX package.
Declaration
public static void RemoveDigitalSignatures(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path |
RemoveNotesFromAllSlides()
Removes notes from all slides in the presentation.
Declaration
public int RemoveNotesFromAllSlides()
Returns
| Type | Description |
|---|---|
| int | The number of slides whose notes were removed. |
RemoveWriteProtection()
Removes write-protection metadata from the current presentation instance.
Declaration
public void RemoveWriteProtection()
Replace(string, string, StringComparison)
Replaces all matches across all slides and returns the total number of replacements.
Declaration
public int Replace(string oldValue, string newValue, StringComparison comparison = StringComparison.Ordinal)
Parameters
| Type | Name | Description |
|---|---|---|
| string | oldValue | |
| string | newValue | |
| StringComparison | comparison |
Returns
| Type | Description |
|---|---|
| int |
Save(Stream)
Saves the presentation to the specified stream in PPTX format.
Declaration
public void Save(Stream stream)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream |
Save(string, FormatType)
Saves the presentation to disk at the specified path.
Declaration
public void Save(string path, FormatType formatType = FormatType.PowerPointPresentation)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | |
| FormatType | formatType |
Save(string, FormatType, PptxSaveOptions)
Saves the presentation to disk using explicit format and PPTX security options.
Declaration
public void Save(string path, FormatType formatType, PptxSaveOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | |
| FormatType | formatType | |
| PptxSaveOptions | options |
Remarks
When formatType is ODP, PPTX encryption, password,
digital-signature, and JavaScript-link options are rejected. Signed-package
rewrite flags are ignored because ODP output is not a signed PPTX package.
Save(string, FormatType, PresentationMode)
Saves the presentation using the specified serialization mode for this write. The presentation's existing mode is restored after the save completes.
Declaration
public void Save(string path, FormatType formatType, PresentationMode mode)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The output file path. |
| FormatType | formatType | The target presentation format. |
| PresentationMode | mode | The serialization mode to use while writing. |
Save(string, FormatType, string)
Saves the presentation to disk and encrypts the package with the specified password.
Declaration
public void Save(string path, FormatType formatType, string password)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | |
| FormatType | formatType | |
| string | password |
Save(string, PptxSaveOptions)
Saves the presentation to disk using PPTX security options.
Declaration
public void Save(string path, PptxSaveOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | |
| PptxSaveOptions | options |
Save(string, SaveOptions)
Saves the presentation to disk using the specified SaveOptions. The options type determines the output format:
- PptxSaveOptions — PPTX format.
- PdfSaveOptions — PDF format.
- ImageSaveOptions — raster image format (PNG, JPEG, TIFF).
- TiffOptions — TIFF format with compression.
- SvgOptions — SVG format.
- HtmlOptions — HTML format.
- XpsSaveOptions — XPS format (not yet implemented).
Declaration
public void Save(string path, SaveOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The output file path. |
| SaveOptions | options | The save options. Must not be null. |
SaveSigned(string, PptxDigitalSignatureSaveOptions)
Saves the presentation and applies a single digital signature.
Declaration
public void SaveSigned(string path, PptxDigitalSignatureSaveOptions signature)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | |
| PptxDigitalSignatureSaveOptions | signature |
SaveSigned(string, IEnumerable<PptxDigitalSignatureSaveOptions>)
Saves the presentation and applies multiple digital signatures.
Declaration
public void SaveSigned(string path, IEnumerable<PptxDigitalSignatureSaveOptions> signatures)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | |
| IEnumerable<PptxDigitalSignatureSaveOptions> | signatures |
VerifyDigitalSignatures(string)
Verifies all digital signatures in an existing unencrypted PPTX package.
Declaration
public static bool VerifyDigitalSignatures(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The path to the PPTX package. |
Returns
| Type | Description |
|---|---|
| bool | true when every package signature verifies; otherwise, false. |