Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active September 9, 2021 11:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/53618a1474fae5c208b4305cbae33746 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/53618a1474fae5c208b4305cbae33746 to your computer and use it in GitHub Desktop.
Create PowerPoint Presentation in ASP.NET
// 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);
// Get slide collection
ISlideCollection slds = presentation.Slides;
// Add an empty slide to the Slides collection
ISlide sld = slds.AddEmptySlide(presentation.LayoutSlides[0]);
// 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 title
((IAutoShape)sld.Shapes[0]).TextFrame.Text = "Slide Title Heading";
// 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);
}
// Create an instance of presentation
Presentation presentation = new Presentation();
// Load presentation
Presentation presentation = new Presentation("presentation.pptx");
// Save the presentation to disk
presentation.Save("presentation.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
// 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