API Reference
PowerPointPresentation
Represents a PowerPoint presentation providing basic create, open and save operations.
Inheritance
- Object
- PowerPointPresentation
Methods
public Void AddColumnGuides(Int32 columnCount, Int64 marginEmus, Int64 gutterEmus, Boolean includeOuterEdges = true, Boolean clearExisting = false) #VoidAdds vertical column guides based on a grid definition.
Parameters
- columnCount System.Int32
- marginEmus System.Int64
- gutterEmus System.Int64
- includeOuterEdges System.Boolean = true
- clearExisting System.Boolean = false
public Void AddColumnGuidesCm(Int32 columnCount, Double marginCm, Double gutterCm, Boolean includeOuterEdges = true, Boolean clearExisting = false) #VoidAdds vertical column guides using centimeters.
Parameters
- columnCount System.Int32
- marginCm System.Double
- gutterCm System.Double
- includeOuterEdges System.Boolean = true
- clearExisting System.Boolean = false
public Void AddGuide(PowerPointGuideOrientation orientation, Int64 positionEmus) #VoidAdds a guide to slide view.
Parameters
- orientation OfficeIMO.PowerPoint.PowerPointGuideOrientation
- positionEmus System.Int64
public Void AddGuideCm(PowerPointGuideOrientation orientation, Double positionCm) #VoidAdds a guide using centimeter measurements.
Parameters
- orientation OfficeIMO.PowerPoint.PowerPointGuideOrientation
- positionCm System.Double
public Void AddGuideInches(PowerPointGuideOrientation orientation, Double positionInches) #VoidAdds a guide using inch measurements.
Parameters
- orientation OfficeIMO.PowerPoint.PowerPointGuideOrientation
- positionInches System.Double
public Void AddGuidePoints(PowerPointGuideOrientation orientation, Double positionPoints) #VoidAdds a guide using point measurements.
Parameters
- orientation OfficeIMO.PowerPoint.PowerPointGuideOrientation
- positionPoints System.Double
public Void AddRowGuides(Int32 rowCount, Int64 marginEmus, Int64 gutterEmus, Boolean includeOuterEdges = true, Boolean clearExisting = false) #VoidAdds horizontal row guides based on a grid definition.
Parameters
- rowCount System.Int32
- marginEmus System.Int64
- gutterEmus System.Int64
- includeOuterEdges System.Boolean = true
- clearExisting System.Boolean = false
public Void AddRowGuidesCm(Int32 rowCount, Double marginCm, Double gutterCm, Boolean includeOuterEdges = true, Boolean clearExisting = false) #VoidAdds horizontal row guides using centimeters.
Parameters
- rowCount System.Int32
- marginCm System.Double
- gutterCm System.Double
- includeOuterEdges System.Boolean = true
- clearExisting System.Boolean = false
public PowerPointSectionInfo AddSection(String name, Int32 startSlideIndex) #PowerPointSectionInfoAdds a new section starting at the specified slide index.
Parameters
- name System.String
- startSlideIndex System.Int32
public PowerPointSlide AddSlide(SlideLayoutValues layoutType, Int32 masterIndex = 0) #PowerPointSlideAdds a slide using a layout type.
Parameters
- arg1 DocumentFormat.OpenXml.Presentation.SlideLayoutValues
- arg2 System.Int32 = 0
public PowerPointSlide AddSlide(String layoutName, Int32 masterIndex = 0, Boolean ignoreCase = true) #PowerPointSlideAdds a slide using a layout name.
Parameters
- layoutName System.String
- masterIndex System.Int32 = 0
- ignoreCase System.Boolean = true
public PowerPointSlide AddSlide(Int32 masterIndex = 0, Int32 layoutIndex = 0) #PowerPointSlideAdds a new slide using the specified master and layout indexes.
Parameters
- masterIndex System.Int32 = 0
- Index of the slide master.
- layoutIndex System.Int32 = 0
- Index of the slide layout.
public PowerPointFluentPresentation AsFluent() #PowerPointFluentPresentationCreates a fluent wrapper for this presentation.
public static PowerPointPresentation Create(String filePath) #PowerPointPresentationCreates a new PowerPoint presentation at the specified file path.
Parameters
- filePath System.String
- Path where the presentation file will be created.
public static PowerPointPresentation Create(Stream stream, Boolean autoSave = true) #PowerPointPresentationCreates a new PowerPoint presentation in memory and optionally persists it to the provided stream on dispose.
Parameters
- stream System.IO.Stream
- Destination stream for the presentation package.
- autoSave System.Boolean = true
- When true, writes the package back to the stream on dispose.
public PowerPointSlide DuplicateSlide(Int32 index, Nullable<Int32> insertAt = null) #PowerPointSlideDuplicates a slide and inserts it into the presentation.
Parameters
- index System.Int32
- Index of the slide to duplicate.
- insertAt System.Nullable{System.Int32} = null
- Index where the duplicate should be inserted. Defaults to index + 1.
public PowerPointTextBox EnsureLayoutPlaceholderTextBox(Int32 masterIndex, Int32 layoutIndex, PlaceholderValues placeholderType, Nullable<UInt32> index = null, Nullable<PowerPointLayoutBox> bounds = null, String name = null) #PowerPointTextBoxEnsures a layout placeholder textbox exists, creating it if missing.
Parameters
- masterIndex System.Int32
- layoutIndex System.Int32
- placeholderType DocumentFormat.OpenXml.Presentation.PlaceholderValues
- index System.Nullable{System.UInt32} = null
- bounds System.Nullable{OfficeIMO.PowerPoint.PowerPointLayoutBox} = null
- name System.String = null
public IReadOnlyList<PowerPointGuideInfo> GetGuides() #IReadOnlyList<PowerPointGuideInfo>Returns the current guides defined for slide view.
public Int32 GetLayoutIndex(SlideLayoutValues layoutType, Int32 masterIndex = 0) #Int32Finds a layout index by layout type.
Parameters
- layoutType DocumentFormat.OpenXml.Presentation.SlideLayoutValues
- masterIndex System.Int32 = 0
public Int32 GetLayoutIndex(String layoutName, Int32 masterIndex = 0, Boolean ignoreCase = true) #Int32Finds a layout index by layout name.
Parameters
- layoutName System.String
- masterIndex System.Int32 = 0
- ignoreCase System.Boolean = true
public PowerPointTextBox GetLayoutPlaceholderTextBox(Int32 masterIndex, Int32 layoutIndex, PlaceholderValues placeholderType, Nullable<UInt32> index = null) #PowerPointTextBoxRetrieves a layout placeholder textbox for a master/layout pair.
Parameters
- masterIndex System.Int32
- layoutIndex System.Int32
- placeholderType DocumentFormat.OpenXml.Presentation.PlaceholderValues
- index System.Nullable{System.UInt32} = null
public IReadOnlyList<PowerPointSectionInfo> GetSections() #IReadOnlyList<PowerPointSectionInfo>Returns the sections defined in the presentation.
public IReadOnlyList<PowerPointSlideLayoutInfo> GetSlideLayouts(Int32 masterIndex = 0) #IReadOnlyList<PowerPointSlideLayoutInfo>Returns the layouts available for a slide master.
Parameters
- masterIndex System.Int32 = 0
public String GetThemeColor(PowerPointThemeColor color, Int32 masterIndex = 0) #StringGets a theme color value in hex format (e.g. "FF0000").
Parameters
- color OfficeIMO.PowerPoint.PowerPointThemeColor
- masterIndex System.Int32 = 0
public IReadOnlyDictionary<PowerPointThemeColor, String> GetThemeColors(Int32 masterIndex = 0) #IReadOnlyDictionary<PowerPointThemeColor, String>Returns the theme colors that are defined on the master.
Parameters
- masterIndex System.Int32 = 0
public PowerPointThemeFontSet GetThemeFonts(Int32 masterIndex = 0) #PowerPointThemeFontSetGets the major/minor fonts (Latin, East Asian, and complex script).
Parameters
- masterIndex System.Int32 = 0
public PowerPointThemeFontInfo GetThemeLatinFonts(Int32 masterIndex = 0) #PowerPointThemeFontInfoGets the major/minor Latin fonts for the theme.
Parameters
- masterIndex System.Int32 = 0
public PowerPointSlide ImportSlide(PowerPointPresentation sourcePresentation, Int32 sourceIndex, Nullable<Int32> insertAt = null) #PowerPointSlideImports a slide from another presentation and inserts it into the current presentation.
Parameters
- sourcePresentation OfficeIMO.PowerPoint.PowerPointPresentation
- Presentation to import from.
- sourceIndex System.Int32
- Index of the slide to import.
- insertAt System.Nullable{System.Int32} = null
- Index where the imported slide should be inserted. Defaults to end.
public Void MoveSlide(Int32 fromIndex, Int32 toIndex) #VoidMoves a slide from one index to another.
Parameters
- fromIndex System.Int32
- Current index of the slide.
- toIndex System.Int32
- Destination index of the slide.
public static PowerPointPresentation Open(String filePath) #PowerPointPresentationOpens an existing PowerPoint presentation.
Parameters
- filePath System.String
- Path of the presentation file to open.
public static PowerPointPresentation Open(Stream stream, Boolean readOnly = false, Boolean autoSave = false) #PowerPointPresentationOpens a PowerPoint presentation from a stream.
Parameters
- stream System.IO.Stream
- Source stream containing the presentation package.
- readOnly System.Boolean = false
- Open the document in read-only mode.
- autoSave System.Boolean = false
- When true, writes the package back to the stream on dispose.
public static PowerPointPresentation OpenRead(String filePath) #PowerPointPresentationOpens an existing PowerPoint presentation in read-only mode (no writes, no repairs).
Parameters
- filePath System.String
- Path of the presentation file to open.
public Void RemoveSlide(Int32 index) #VoidRemoves the slide at the specified index.
Parameters
- index System.Int32
- Index of the slide to remove.
public Boolean RenameSection(String name, String newName, Boolean ignoreCase = true) #BooleanRenames the first section matching the provided name.
Parameters
- name System.String
- newName System.String
- ignoreCase System.Boolean = true
public Int32 ReplaceText(String oldValue, String newValue, Boolean includeTables = true, Boolean includeNotes = false) #Int32Replaces text across all slides.
Parameters
- oldValue System.String
- newValue System.String
- includeTables System.Boolean = true
- includeNotes System.Boolean = false
public Void SetGridSpacing(Int64 xEmus, Int64 yEmus) #VoidSets grid spacing in EMUs.
Parameters
- xEmus System.Int64
- yEmus System.Int64
public Void SetGridSpacingCm(Double xCm, Double yCm) #VoidSets grid spacing in centimeters.
Parameters
- xCm System.Double
- yCm System.Double
public Void SetGridSpacingInches(Double xInches, Double yInches) #VoidSets grid spacing in inches.
Parameters
- xInches System.Double
- yInches System.Double
public Void SetGridSpacingPoints(Double xPoints, Double yPoints) #VoidSets grid spacing in points.
Parameters
- xPoints System.Double
- yPoints System.Double
public Void SetGuides(IEnumerable<PowerPointGuideInfo> guides) #VoidSets the guide list to the provided collection.
Parameters
- guides System.Collections.Generic.IEnumerable{OfficeIMO.PowerPoint.PowerPointGuideInfo}
public Void SetLayoutPlaceholderBounds(Int32 masterIndex, Int32 layoutIndex, PlaceholderValues placeholderType, PowerPointLayoutBox bounds, Nullable<UInt32> index = null, Boolean createIfMissing = false) #VoidSets layout placeholder bounds.
Parameters
- masterIndex System.Int32
- layoutIndex System.Int32
- placeholderType DocumentFormat.OpenXml.Presentation.PlaceholderValues
- bounds OfficeIMO.PowerPoint.PowerPointLayoutBox
- index System.Nullable{System.UInt32} = null
- createIfMissing System.Boolean = false
public Void SetLayoutPlaceholderTextMarginsCm(Int32 masterIndex, Int32 layoutIndex, PlaceholderValues placeholderType, Double leftCm, Double topCm, Double rightCm, Double bottomCm, Nullable<UInt32> index = null, Boolean createIfMissing = false) #VoidSets layout placeholder text margins in centimeters.
Parameters
- masterIndex System.Int32
- layoutIndex System.Int32
- placeholderType DocumentFormat.OpenXml.Presentation.PlaceholderValues
- leftCm System.Double
- topCm System.Double
- rightCm System.Double
- bottomCm System.Double
- index System.Nullable{System.UInt32} = null
- createIfMissing System.Boolean = false
public Void SetLayoutPlaceholderTextMarginsInches(Int32 masterIndex, Int32 layoutIndex, PlaceholderValues placeholderType, Double leftInches, Double topInches, Double rightInches, Double bottomInches, Nullable<UInt32> index = null, Boolean createIfMissing = false) #VoidSets layout placeholder text margins in inches.
Parameters
- masterIndex System.Int32
- layoutIndex System.Int32
- placeholderType DocumentFormat.OpenXml.Presentation.PlaceholderValues
- leftInches System.Double
- topInches System.Double
- rightInches System.Double
- bottomInches System.Double
- index System.Nullable{System.UInt32} = null
- createIfMissing System.Boolean = false
public Void SetLayoutPlaceholderTextMarginsPoints(Int32 masterIndex, Int32 layoutIndex, PlaceholderValues placeholderType, Double leftPoints, Double topPoints, Double rightPoints, Double bottomPoints, Nullable<UInt32> index = null, Boolean createIfMissing = false) #VoidSets layout placeholder text margins in points.
Parameters
- masterIndex System.Int32
- layoutIndex System.Int32
- placeholderType DocumentFormat.OpenXml.Presentation.PlaceholderValues
- leftPoints System.Double
- topPoints System.Double
- rightPoints System.Double
- bottomPoints System.Double
- index System.Nullable{System.UInt32} = null
- createIfMissing System.Boolean = false
public Void SetLayoutPlaceholderTextStyle(Int32 masterIndex, Int32 layoutIndex, PlaceholderValues placeholderType, PowerPointTextStyle style, Nullable<UInt32> index = null, Nullable<Int32> level = null, Nullable<Char> bulletChar = null, Nullable<TextAutoNumberSchemeValues> numbering = null, Boolean createIfMissing = false) #VoidSets layout placeholder text styling and optional bullet settings.
Parameters
- masterIndex System.Int32
- layoutIndex System.Int32
- placeholderType DocumentFormat.OpenXml.Presentation.PlaceholderValues
- style OfficeIMO.PowerPoint.PowerPointTextStyle
- index System.Nullable{System.UInt32} = null
- level System.Nullable{System.Int32} = null
- bulletChar System.Nullable{System.Char} = null
- numbering System.Nullable{DocumentFormat.OpenXml.Drawing.TextAutoNumberSchemeValues} = null
- createIfMissing System.Boolean = false
public Void SetThemeColor(PowerPointThemeColor color, String hexValue, Int32 masterIndex = 0) #VoidSets a theme color value in hex format (e.g. "FF0000").
Parameters
- color OfficeIMO.PowerPoint.PowerPointThemeColor
- hexValue System.String
- masterIndex System.Int32 = 0
public Void SetThemeColorForAllMasters(PowerPointThemeColor color, String hexValue) #VoidSets a theme color value across all masters.
Parameters
- color OfficeIMO.PowerPoint.PowerPointThemeColor
- hexValue System.String
public Void SetThemeColors(IDictionary<PowerPointThemeColor, String> colors, Int32 masterIndex = 0) #VoidSets multiple theme colors at once.
Parameters
- colors System.Collections.Generic.IDictionary{OfficeIMO.PowerPoint.PowerPointThemeColor,System.String}
- masterIndex System.Int32 = 0
public Void SetThemeColorsForAllMasters(IDictionary<PowerPointThemeColor, String> colors) #VoidSets multiple theme colors across all masters.
Parameters
- colors System.Collections.Generic.IDictionary{OfficeIMO.PowerPoint.PowerPointThemeColor,System.String}
public Void SetThemeFonts(PowerPointThemeFontSet fonts, Int32 masterIndex = 0, Boolean keepExistingWhenNull = true) #VoidSets the major/minor fonts (Latin, East Asian, and complex script).
Parameters
- fonts OfficeIMO.PowerPoint.PowerPointThemeFontSet
- masterIndex System.Int32 = 0
- keepExistingWhenNull System.Boolean = true
public Void SetThemeFontsForAllMasters(PowerPointThemeFontSet fonts, Boolean keepExistingWhenNull = true) #VoidSets the major/minor fonts (Latin, East Asian, and complex script) across all masters.
Parameters
- fonts OfficeIMO.PowerPoint.PowerPointThemeFontSet
- keepExistingWhenNull System.Boolean = true
public Void SetThemeLatinFonts(String majorLatin, String minorLatin, Int32 masterIndex = 0) #VoidSets the major/minor Latin fonts for the theme.
Parameters
- majorLatin System.String
- minorLatin System.String
- masterIndex System.Int32 = 0
public Void SetThemeLatinFontsForAllMasters(String majorLatin, String minorLatin) #VoidSets the major/minor Latin fonts across all masters.
Parameters
- majorLatin System.String
- minorLatin System.String
public Void SetThemeNameForAllMasters(String name) #VoidSets the theme name across all masters.
Parameters
- name System.String
public List<ValidationErrorInfo> ValidateDocument(FileFormatVersions fileFormatVersions = Microsoft365) #List<ValidationErrorInfo>Validates the presentation using the specified file format version.
Parameters
- fileFormatVersions DocumentFormat.OpenXml.FileFormatVersions = Microsoft365
- File format version to validate against.
Returns
List of validation errors.
Examples
using (var presentation = PowerPointPresentation.Create("test.pptx")) {
var errors = presentation.ValidateDocument();
if (errors.Count > 0) {
// Handle validation errors
}
}
Inherited Methods
public override Boolean Equals(Object obj) #BooleanParameters
- obj Object
Properties
public IReadOnlyList<PowerPointSlide> Slides { get; } #Collection of slides in the presentation.
public PowerPointSlideSize SlideSize { get; } #Slide size information for the presentation.
public String ThemeName { get; set; } #Gets or sets the name of the presentation theme.
public IReadOnlyList<PowerPointTableStyleInfo> TableStyles { get; } #Gets the list of table styles available in the presentation.
public Boolean SnapToGrid { get; set; } #Gets or sets whether slide view snapping uses the grid.
public Int64 GridSpacingXEmus { get; set; } #Horizontal grid spacing in EMUs.
public Int64 GridSpacingYEmus { get; set; } #Vertical grid spacing in EMUs.
public Boolean DocumentIsValid { get; } #Indicates whether the presentation passes Open XML validation.
public List<ValidationErrorInfo> DocumentValidationErrors { get; } #Gets the list of validation errors for the presentation.
Extension Methods
public static IEnumerable<PowerPointExtractChunk> ExtractMarkdownChunks(PowerPointPresentation presentation, PowerPointExtractOptions extract = null, PowerPointExtractChunkingOptions chunking = null, String sourcePath = null, CancellationToken cancellationToken = null) #IEnumerable<PowerPointExtractChunk>Extracts a presentation into slide-aligned chunks (one chunk per slide by default).
Parameters
- presentation OfficeIMO.PowerPoint.PowerPointPresentation
- extract OfficeIMO.PowerPoint.PowerPointExtractionExtensions.PowerPointExtractOptions = null
- chunking OfficeIMO.PowerPoint.PowerPointExtractChunkingOptions = null
- sourcePath System.String = null
- cancellationToken System.Threading.CancellationToken = null