Learn how to create PowerPoint presentations in ASP.NET: https://blog.aspose.com/2021/09/09/create-edit-powerpoint-files-in-asp-net/
Last active
September 9, 2021 11:24
-
-
Save aspose-com-gists/53618a1474fae5c208b4305cbae33746 to your computer and use it in GitHub Desktop.
Create PowerPoint Presentation in ASP.NET
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
// Add image | |
IPPImage image = presentation.Images.AddImage(File.ReadAllBytes("image.png")); | |
sld.Shapes.AddPictureFrame(ShapeType.Rectangle, 10, 10, 100, 100, image); |
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
// Add autoshape of ellipse type | |
sld.Shapes.AddAutoShape(ShapeType.Ellipse, 50, 150, 150, 50); |
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
// Get slide collection | |
ISlideCollection slds = presentation.Slides; | |
// Add an empty slide to the Slides collection | |
ISlide sld = slds.AddEmptySlide(presentation.LayoutSlides[0]); |
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
// Add an AutoShape of Rectangle type | |
IAutoShape ashp = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 150, 75, 150, 50); | |
// Add TextFrame to the Rectangle | |
ashp.AddTextFrame(" "); | |
// Accessing the text frame | |
ITextFrame txtFrame = ashp.TextFrame; | |
// Create the Paragraph object for text frame | |
IParagraph para = txtFrame.Paragraphs[0]; | |
// Create Portion object for paragraph | |
IPortion portion = para.Portions[0]; | |
// Set Text | |
portion.Text = "Aspose TextBox"; |
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
// Add title | |
((IAutoShape)sld.Shapes[0]).TextFrame.Text = "Slide Title Heading"; |
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
// Create presentation | |
using (Presentation presentation = new Presentation()) | |
{ | |
// Get slide collection | |
ISlideCollection slds = presentation.Slides; | |
// Add an empty slide to the Slides collection | |
ISlide sld = slds.AddEmptySlide(presentation.LayoutSlides[0]); | |
// Set the background color of the first ISlide to Blue | |
sld.Background.Type = BackgroundType.OwnBackground; | |
sld.Background.FillFormat.FillType = FillType.Solid; | |
sld.Background.FillFormat.SolidFillColor.Color = Color.Blue; | |
// Add title | |
((IAutoShape)sld.Shapes[0]).TextFrame.Text = "Slide Title Heading"; | |
// Add an AutoShape of Rectangle type | |
IAutoShape ashp = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 150, 75, 150, 50); | |
// Add TextFrame to the Rectangle | |
ashp.AddTextFrame(" "); | |
// Accessing the text frame | |
ITextFrame txtFrame = ashp.TextFrame; | |
// Create the Paragraph object for text frame | |
IParagraph para = txtFrame.Paragraphs[0]; | |
// Create Portion object for paragraph | |
IPortion portion = para.Portions[0]; | |
// Set Text | |
portion.Text = "Aspose TextBox"; | |
// Add image | |
IPPImage image = presentation.Images.AddImage(File.ReadAllBytes("image.png")); | |
sld.Shapes.AddPictureFrame(ShapeType.Rectangle, 10, 10, 100, 100, image); | |
// Add autoshape of ellipse type | |
sld.Shapes.AddAutoShape(ShapeType.Ellipse, 50, 150, 150, 50); | |
// Save the presentation to disk | |
presentation.Save("presentation.pptx", Aspose.Slides.Export.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
// Create an instance of presentation | |
Presentation presentation = new Presentation(); |
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 presentation | |
Presentation presentation = new Presentation("presentation.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
// Save the presentation to disk | |
presentation.Save("presentation.pptx", Aspose.Slides.Export.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
// Set the background color of the first ISlide to Blue | |
sld.Background.Type = BackgroundType.OwnBackground; | |
sld.Background.FillFormat.FillType = FillType.Solid; | |
sld.Background.FillFormat.SolidFillColor.Color = Color.Blue; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment