private void btnRun_Click(object sender, EventArgs e) { //create PPT document Presentation presentation = new Presentation(); //add new slide presentation.Slides.Append(); //add new slide presentation.Slides.Append(); //set the background of the first slide to Gradient color presentation.Slides[0].SlideBackground.Type = BackgroundType.Custom; presentation.Slides[0].SlideBackground.Fill.FillType = FillFormatType.Gradient; presentation.Slides[0].SlideBackground.Fill.Gradient.GradientShape = GradientShapeType.Linear; presentation.Slides[0].SlideBackground.Fill.Gradient.GradientStyle = Spire.Presentation.Drawing.GradientStyle.FromCorner1; presentation.Slides[0].SlideBackground.Fill.Gradient.GradientStops.Append(1f, KnownColors.LightGreen); presentation.Slides[0].SlideBackground.Fill.Gradient.GradientStops.Append(0f, KnownColors.White); //set the background of the second slide to Solid color presentation.Slides[1].SlideBackground.Type = BackgroundType.Custom; presentation.Slides[1].SlideBackground.Fill.FillType = FillFormatType.Solid; presentation.Slides[1].SlideBackground.Fill.SolidColor.Color = Color.DarkSeaGreen; //set the background of the third slide to picture string ImageFile = @"..\..\..\..\..\..\Data\background.png"; RectangleF rect = new RectangleF(0, 0, presentation.SlideSize.Size.Width, presentation.SlideSize.Size.Height); presentation.Slides[2].SlideBackground.Fill.FillType = FillFormatType.Picture; IEmbedImage image = presentation.Slides[2].Shapes.AppendEmbedImage(ShapeType.Rectangle, ImageFile, rect); presentation.Slides[2].SlideBackground.Fill.PictureFill.Picture.EmbedImage = image as IImageData; //add shape and fill it with text in slides IAutoShape shape; TextRange textRange; for (int i = 0; i < 3; i++) { shape = presentation.Slides[i].Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(50, 70, 600, 100)); shape.ShapeStyle.LineColor.Color = Color.White; shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None; shape.AppendTextFrame("Demonstrates to how to set the background style of slides."); //set the Font and fill style textRange = shape.TextFrame.TextRange; textRange.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid; textRange.Fill.SolidColor.Color = Color.Black; textRange.LatinFont = new TextFont("Arial Black"); } //save the document presentation.SaveToFile("background.pptx", FileFormat.Pptx2010); System.Diagnostics.Process.Start("background.pptx"); }
private void button3_Click(object sender, EventArgs e) { Presentation presentation = new Presentation(); presentation.LoadFromFile(fileName); IMasterSlide master = presentation.Masters[0]; String image = @"logo.png"; RectangleF rff = new RectangleF(40, 40, 100, 80); IEmbedImage pic = master.Shapes.AppendEmbedImage(ShapeType.Rectangle, image, rff); pic.Line.FillFormat.FillType = FillFormatType.None; presentation.Slides.Append(); presentation.SaveToFile("result.pptx", FileFormat.Auto); System.Diagnostics.Process.Start("result.pptx"); }
private void btnRun_Click(object sender, EventArgs e) { //create PPT document Presentation presentation = new Presentation(); //set background Image string ImageFile = @"..\..\..\..\..\..\Data\bg.png"; RectangleF rect = new RectangleF(0, 0, presentation.SlideSize.Size.Width, presentation.SlideSize.Size.Height); presentation.Slides[0].Shapes.AppendEmbedImage(ShapeType.Rectangle, ImageFile, rect); presentation.Slides[0].Shapes[0].Line.FillFormat.SolidFillColor.Color = Color.FloralWhite; //add title RectangleF rec_title = new RectangleF(presentation.SlideSize.Size.Width / 2 - 200, 70, 400, 50); IAutoShape shape_title = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, rec_title); shape_title.ShapeStyle.LineColor.Color = Color.White; shape_title.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None; TextParagraph para_title = new TextParagraph(); para_title.Text = "Insert Image"; para_title.Alignment = TextAlignmentType.Center; para_title.TextRanges[0].LatinFont = new TextFont("Myriad Pro Light"); para_title.TextRanges[0].FontHeight = 36; para_title.TextRanges[0].Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid; para_title.TextRanges[0].Fill.SolidColor.Color = Color.Black; shape_title.TextFrame.Paragraphs.Append(para_title); //insert image to PPT string ImageFile2 = @"..\..\..\..\..\..\Data\PresentationNET.png"; RectangleF rect1 = new RectangleF(presentation.SlideSize.Size.Width / 2 - 300, 170, 110, 120); IEmbedImage image = presentation.Slides[0].Shapes.AppendEmbedImage(ShapeType.Rectangle, ImageFile2, rect1); image.Line.FillType = FillFormatType.None; //add new shape to PPT document RectangleF rec = new RectangleF(presentation.SlideSize.Size.Width / 2 - 190, 155, 490, 160); IAutoShape shape = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, rec); shape.ShapeStyle.LineColor.Color = Color.White; shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None; //add text to shape shape.AppendTextFrame("Spire.Presentation for .NET is a professional PowerPoint compatible component that enables developers to create, read, write, modify, convert and Print PowerPoint documents from any .NET(C#, VB.NET, ASP.NET) platform. As an independent PowerPoint .NET component, Spire.Presentation for .NET doesn't need Microsoft PowerPoint installed on the machine."); //set the font and fill style of text TextParagraph paragraph = shape.TextFrame.Paragraphs[0]; paragraph.TextRanges[0].Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid; paragraph.TextRanges[0].Fill.SolidColor.Color = Color.Black; paragraph.TextRanges[0].FontHeight = 20; paragraph.TextRanges[0].LatinFont = new TextFont("Myriad Pro"); paragraph.Alignment = TextAlignmentType.Left; //add new shape to PPT document RectangleF rec2 = new RectangleF(presentation.SlideSize.Size.Width / 2 - 300, 320, 600, 130); IAutoShape shape2 = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, rec2); shape2.ShapeStyle.LineColor.Color = Color.White; shape2.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None; //add text to shape shape2.AppendTextFrame("Spire.Presentation for .NET support PPT, PPS, PPTX and PPSX presentation formats. It provides functions such as managing text, image, shapes, tables, animations, audio and video on slides. It also support exporting presentation slides to EMF, JPG, TIFF, PDF format etc."); //set the font and fill style of text TextParagraph paragraph2 = shape2.TextFrame.Paragraphs[0]; paragraph2.TextRanges[0].Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid; paragraph2.TextRanges[0].Fill.SolidColor.Color = Color.Black; paragraph2.TextRanges[0].FontHeight = 20; paragraph2.TextRanges[0].LatinFont = new TextFont("Myriad Pro"); paragraph2.Alignment = TextAlignmentType.Left; //save the document presentation.SaveToFile("InsertPicture.pptx", FileFormat.Pptx2010); System.Diagnostics.Process.Start("InsertPicture.pptx"); }
static void Main(string[] args) { Presentation ppt = new Presentation(); ISlide slide = ppt.Slides[0]; SizeF pptSize = ppt.SlideSize.Size; //Set background string bgFile = "bg.jpg"; RectangleF bgRect = new RectangleF(new PointF(0, 0), pptSize); slide.Shapes.AppendEmbedImage(ShapeType.Rectangle, bgFile, bgRect); //Add title RectangleF titleRect = new RectangleF(pptSize.Width / 2 - 200, 10, 400, 50); IAutoShape titleShape = slide.Shapes.AppendShape(ShapeType.Rectangle, titleRect); titleShape.Fill.FillType = FillFormatType.None; titleShape.ShapeStyle.LineColor.Color = Color.Empty; TextParagraph titlePara = titleShape.TextFrame.Paragraphs[0]; titlePara.Text = "Microsoft PowerPoint"; titlePara.FirstTextRange.FontHeight = 36; titlePara.FirstTextRange.Fill.FillType = FillFormatType.Solid; titlePara.FirstTextRange.Fill.SolidColor.Color = Color.Black; titlePara.Alignment = TextAlignmentType.Center; //Insert Image string logoFile = "logo.png"; RectangleF logoRect = new RectangleF(pptSize.Width / 2 - 40, 60, 80, 80); IEmbedImage image = slide.Shapes.AppendEmbedImage(ShapeType.Rectangle, logoFile, logoRect); image.Line.FillType = FillFormatType.None; //Insert Table and apply built-in table style double[] widths = { 160, 320 }; double[] heights = { 15, 15, 15, 15, 15, 15, 15 }; ITable table = slide.Shapes.AppendTable(pptSize.Width / 2 - 240, 150, widths, heights); string[,] data = new string[, ] { { "Developer(s)", "Microsoft" }, { "Stable Release", "2013/10,2,2012; 2 years ago" }, { "Written In", "C++" }, { "Operation System", "Microsoft Windows" }, { "Type", "Presentation Program" }, { "License", "Trialware" }, { "Website", "http://office.microsoft.com/powerpoint" } }; for (int i = 0; i < 7; i++) { for (int j = 0; j < 2; j++) { table[j, i].TextFrame.Text = data[i, j]; } } table.StylePreset = TableStylePreset.LightStyle3Accent5; //Add hyperlink ClickHyperlink hyperlink = new ClickHyperlink("http://office.microsoft.com/powerpoint"); table[1, 6].TextFrame.TextRange.ClickAction = hyperlink; //Add content RectangleF textRect = new RectangleF(pptSize.Width / 2 - 240, 365, 480, 130); IAutoShape textShape = slide.Shapes.AppendShape(ShapeType.Rectangle, textRect); //Content format string text = File.ReadAllText("description.txt"); textShape.AppendTextFrame(text); TextParagraph contentPara = textShape.TextFrame.Paragraphs[0]; contentPara.FirstTextRange.Fill.FillType = FillFormatType.Solid; contentPara.FirstTextRange.Fill.SolidColor.Color = Color.Black; contentPara.Alignment = TextAlignmentType.Left; //Shape format textShape.ShapeStyle.LineColor.Color = Color.Empty; textShape.Fill.FillType = FillFormatType.Gradient; textShape.Fill.Gradient.GradientStops.Append(0, Color.LightBlue); textShape.Fill.Gradient.GradientStops.Append(1, Color.LightGreen); //Set footer ppt.SetDateTimeVisible(true); ppt.SetSlideNoVisible(true); //Set transition of slide slide.SlideShowTransition.Type = TransitionType.Cover; //Save the file ppt.SaveToFile("result.pptx", FileFormat.Pptx2010); }
private void btnRun_Click(object sender, EventArgs e) { //create PPT document Presentation presentation = new Presentation(); //set background Image string ImageFile = @"..\..\..\..\..\..\Data\bg.png"; RectangleF rect = new RectangleF(0, 0, presentation.SlideSize.Size.Width, presentation.SlideSize.Size.Height); presentation.Slides[0].Shapes.AppendEmbedImage(ShapeType.Rectangle, ImageFile, rect); presentation.Slides[0].Shapes[0].Line.FillFormat.SolidFillColor.Color = Color.FloralWhite; //add title RectangleF rec_title = new RectangleF(presentation.SlideSize.Size.Width / 2 - 200, 70, 400, 50); IAutoShape shape_title = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, rec_title); shape_title.ShapeStyle.LineColor.Color = Color.White; shape_title.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None; TextParagraph para_title = new TextParagraph(); para_title.Text = "Document Property"; para_title.Alignment = TextAlignmentType.Center; para_title.TextRanges[0].LatinFont = new TextFont("Myriad Pro Light"); para_title.TextRanges[0].FontHeight = 36; para_title.TextRanges[0].Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid; para_title.TextRanges[0].Fill.SolidColor.Color = Color.Black; shape_title.TextFrame.Paragraphs.Append(para_title); //set the DocumentProperty of PPT document presentation.DocumentProperty.Application = "Spire.Presentation"; presentation.DocumentProperty.Author = "http://www.e-iceblue.com/"; presentation.DocumentProperty.Company = "E-iceblue"; presentation.DocumentProperty.Keywords = "Demo File"; presentation.DocumentProperty.Comments = "This file tests Spire.Presentation."; presentation.DocumentProperty.Category = "Demo"; presentation.DocumentProperty.Title = "This is a demo file."; presentation.DocumentProperty.Subject = "Test"; //insert image to PPT string ImageFile2 = @"..\..\..\..\..\..\Data\Property.png"; RectangleF rect1 = new RectangleF(presentation.SlideSize.Size.Width / 2 - 300, 155, 300, 200); IEmbedImage image = presentation.Slides[0].Shapes.AppendEmbedImage(ShapeType.Rectangle, ImageFile2, rect1); image.Line.FillType = FillFormatType.None; //add new shape to PPT document RectangleF rec = new RectangleF(presentation.SlideSize.Size.Width / 2 - 300, 370, 600, 120); IAutoShape shape = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, rec); shape.ShapeStyle.LineColor.Color = Color.White; shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None; //add text to shape shape.AppendTextFrame("Spire.Presentation for .NET support PPT, PPS, PPTX and PPSX presentation formats. It provides functions such as managing text, image, shapes, tables, animations, audio and video on slides. It also support exporting presentation slides to EMF, JPG, TIFF, PDF format etc."); //set the font and fill style of text TextParagraph paragraph = shape.TextFrame.Paragraphs[0]; paragraph.TextRanges[0].Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid; paragraph.TextRanges[0].Fill.SolidColor.Color = Color.Black; paragraph.TextRanges[0].FontHeight = 20; paragraph.TextRanges[0].LatinFont = new TextFont("Myriad Pro"); paragraph.Alignment = TextAlignmentType.Left; //save the document presentation.SaveToFile("DocumentProperty.pptx", FileFormat.Pptx2007); System.Diagnostics.Process.Start("DocumentProperty.pptx"); }