Learn how to apply themes in PowerPoint presentations using C#: https://blog.aspose.com/2021/09/16/apply-theme-in-powerpoint-using-csharp/
Last active
September 16, 2021 15:57
-
-
Save aspose-com-gists/5a740f14f61859a0c6a5b59591e263ac to your computer and use it in GitHub Desktop.
Apply Theme in PowerPoint Presentations using C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (Presentation pres = new Presentation()) | |
{ | |
// Check number of styles | |
int numberOfBackgroundFills = pres.MasterTheme.FormatScheme.BackgroundFillStyles.Count; | |
if (numberOfBackgroundFills > 0) | |
{ | |
// Select a style | |
pres.Masters[0].Background.StyleIndex = 1; | |
} | |
// Save presentation | |
pres.Save("theme.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load or create presentation | |
using (Presentation pres = new Presentation()) | |
{ | |
// Add shape and set its color | |
IAutoShape shape = pres.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, 10, 10, 100, 100); | |
shape.FillFormat.FillType = FillType.Solid; | |
shape.FillFormat.SolidFillColor.SchemeColor = SchemeColor.Accent1; | |
// Save presentation | |
pres.Save("theme.pptx", SaveFormat.Pptx); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load or create presentation | |
using (Presentation pres = new Presentation()) | |
{ | |
// Add shape and set its color | |
IAutoShape shape = pres.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, 10, 10, 100, 100); | |
// Add paragraph | |
Paragraph paragraph = new Paragraph(); | |
Portion portion = new Portion("Theme text format"); | |
paragraph.Portions.Add(portion); | |
shape.TextFrame.Paragraphs.Add(paragraph); | |
// Set font | |
portion.PortionFormat.LatinFont = new FontData("+mn-lt"); | |
// Save presentation | |
pres.Save("theme.pptx", SaveFormat.Pptx); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment