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 = "Background"; 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); //add new shape to PPT document RectangleF rec = new RectangleF(presentation.SlideSize.Size.Width / 2 - 300, 155, 600, 300); 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."); TextParagraph para = new TextParagraph(); para.Text = "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."; shape.TextFrame.Paragraphs.Append(para); //set the font and fill style of text foreach (TextParagraph paragraph in shape.TextFrame.Paragraphs) { 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; } //set spacing after shape.TextFrame.Paragraphs[0].SpaceAfter = 80; //save the document presentation.SaveToFile("background.pptx", FileFormat.Pptx2010); System.Diagnostics.Process.Start("background.pptx"); }
private void btnRun_Click(object sender, EventArgs e) { //create PPT document Presentation presentation = new Presentation(); //add new shape to PPT document RectangleF rec = new RectangleF(presentation.SlideSize.Size.Width / 2 - 250, 80, 500, 150); 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("Hello World!"); //set the font and fill style of text TextRange textRange = shape.TextFrame.TextRange; textRange.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid; textRange.Fill.SolidColor.Color = Color.Black; textRange.FontHeight = 72; textRange.LatinFont = new TextFont("Myriad Pro Light"); //save the document presentation.SaveToFile("hello.pptx", FileFormat.Pptx2010); System.Diagnostics.Process.Start("hello.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 = "Print"; 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); //append new shape RectangleF rect2 = new RectangleF(presentation.SlideSize.Size.Width / 2 - 300, 155, 600, 270); IAutoShape shape = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, rect2); shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None; //add text to shape shape.AppendTextFrame("This sample demonstrates how to Print PPT file."); //add new paragraph shape.TextFrame.Paragraphs.Append(new TextParagraph()); //add text to paragraph shape.TextFrame.Paragraphs[1].TextRanges.Append(new TextRange("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. 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 foreach (TextParagraph para in shape.TextFrame.Paragraphs) { para.TextRanges[0].LatinFont = new TextFont("Arial Rounded MT Bold"); para.TextRanges[0].Fill.FillType = FillFormatType.Solid; para.TextRanges[0].Fill.SolidColor.Color = Color.Black; para.Alignment = TextAlignmentType.Left; } //print PrinterSettings printerSettings = new PrinterSettings(); presentation.Print(printerSettings); }
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 = "Video"; 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 video into the document RectangleF videoRect = new RectangleF(100, 130, 100, 100); IVideo video = presentation.Slides[0].Shapes.AppendVideoMedia(Path.GetFullPath(@"..\..\..\..\..\..\Data\Spire.Doc Word to HTML.mp4"), videoRect); video.PictureFill.Picture.Url = @"..\..\..\..\..\..\Data\video.bmp"; //add new shape to PPT document RectangleF rec = new RectangleF(presentation.SlideSize.Size.Width / 2 - 300, 255, 600, 150); 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 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("video.pptx", FileFormat.Pptx2010); System.Diagnostics.Process.Start("video.pptx"); }
private static void CreateTitle(Presentation presentation, int slideNumber, string title) { IAutoShape shape = presentation.Slides[slideNumber].Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(287, 15, 150, 20)); shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None; //set the LineColor shape.ShapeStyle.LineColor.Color = Color.White; //set the color and fill style shape.AppendTextFrame(title); //set the color of text in shape TextRange textRange = shape.TextFrame.TextRange; textRange.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.Solid; textRange.Fill.SolidColor.Color = Color.Black; //set the Font of text in shape textRange.FontHeight = 18; textRange.LatinFont = new TextFont("Arial"); }
private void btnRun_Click(object sender, EventArgs e) { //create PPT document Presentation presentation = new Presentation(); //add new slide presentation.Slides.Append(); //set the background image for (int i = 0; i < 2; i++) { string ImageFile = @"..\..\..\..\..\..\Data\bg.png"; RectangleF rect = new RectangleF(0, 0, presentation.SlideSize.Size.Width, presentation.SlideSize.Size.Height); presentation.Slides[i].Shapes.AppendEmbedImage(ShapeType.Rectangle, ImageFile, rect); presentation.Slides[i].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 = "Add Slide"; 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); //append new shape IAutoShape shape = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(50, 150, 600, 280)); shape.ShapeStyle.LineColor.Color = Color.White; shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None; //add text to shape shape.AppendTextFrame("This sample demonstrates how to set Animations in PPT using Spire.Presentation."); //add new paragraph TextParagraph pare = new TextParagraph(); pare.Text = "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."; shape.TextFrame.Paragraphs.Append(pare); //set the Font foreach (TextParagraph para in shape.TextFrame.Paragraphs) { para.TextRanges[0].LatinFont = new TextFont("Myriad Pro"); para.TextRanges[0].FontHeight = 24; para.TextRanges[0].Fill.FillType = FillFormatType.Solid; para.TextRanges[0].Fill.SolidColor.Color = Color.Black; para.Alignment = TextAlignmentType.Left; } //append new shape - SixPointedStar shape = presentation.Slides[1].Shapes.AppendShape(ShapeType.SixPointedStar, new RectangleF(100, 100, 100, 100)); shape.Fill.FillType = FillFormatType.Solid; shape.Fill.SolidColor.Color = Color.Orange; shape.ShapeStyle.LineColor.Color = Color.White; //append new shape shape = presentation.Slides[1].Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(50, 250, 600, 50)); shape.ShapeStyle.LineColor.Color = Color.White; shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None; //add text to shape shape.AppendTextFrame("This is newly added Slide."); //set the Font shape.TextFrame.Paragraphs[0].TextRanges[0].LatinFont = new TextFont("Myriad Pro"); shape.TextFrame.Paragraphs[0].TextRanges[0].FontHeight = 24; shape.TextFrame.Paragraphs[0].TextRanges[0].Fill.FillType = FillFormatType.Solid; shape.TextFrame.Paragraphs[0].TextRanges[0].Fill.SolidColor.Color = Color.Black; shape.TextFrame.Paragraphs[0].Alignment = TextAlignmentType.Left; shape.TextFrame.Paragraphs[0].Indent = 35; //save the document presentation.SaveToFile("slide.pptx", FileFormat.Pptx2010); System.Diagnostics.Process.Start("slide.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 = "Footer"; 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); //add footer presentation.SetFooterText("Demo of Spire.Presentation"); //set the footer visible presentation.SetFooterVisible(true); //set the page number visible presentation.SetSlideNoVisible(true); //set the date visible presentation.SetDateTimeVisible(true); //append new shape RectangleF rect2 = new RectangleF(presentation.SlideSize.Size.Width / 2 - 300, 155, 600, 250); IAutoShape shape = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, rect2); shape.ShapeStyle.LineColor.Color = Color.White; shape.Fill.FillType = Spire.Presentation.Drawing.FillFormatType.None; //add text to shape shape.AppendTextFrame("The sample demonstrates how to use Footer."); //append new paragraph shape.TextFrame.Paragraphs.Append(new TextParagraph()); //add text to paragraph shape.TextFrame.Paragraphs[1].TextRanges.Append(new TextRange("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 foreach (TextParagraph para in shape.TextFrame.Paragraphs) { para.TextRanges[0].LatinFont = new TextFont("Myriad Pro"); para.TextRanges[0].FontHeight = 24; para.TextRanges[0].Fill.FillType = FillFormatType.Solid; para.TextRanges[0].Fill.SolidColor.Color = Color.Black; para.Alignment = TextAlignmentType.Left; } //save the document presentation.SaveToFile("HeaderAndFooter.pptx", FileFormat.Pptx2007); System.Diagnostics.Process.Start("HeaderAndFooter.pptx"); }
private void btnRun_Click(object sender, EventArgs e) { //create PPT document Presentation presentation = new Presentation(); //set the size of slides presentation.SlideSize.Size = new SizeF(500, 600); presentation.SlideSize.Orientation = SlideOrienation.Portrait; presentation.SlideSize.Type = SlideSizeType.Custom; //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 = "Page Size"; 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); //append new shape RectangleF rec = new RectangleF(presentation.SlideSize.Size.Width / 2 - 200, 155, 400, 350); 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("The sample demonstrates how to set the size of slides."); //append new paragraph shape.TextFrame.Paragraphs.Append(new TextParagraph()); //add text to paragraph shape.TextFrame.Paragraphs[1].TextRanges.Append(new TextRange("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. Spire.Presentation for .NET support PPT, PPS, PPTX and PPSX presentation formats.")); //set the Font foreach (TextParagraph para in shape.TextFrame.Paragraphs) { para.TextRanges[0].LatinFont = new TextFont("Myriad Pro"); para.TextRanges[0].FontHeight = 24; para.TextRanges[0].Fill.FillType = FillFormatType.Solid; para.TextRanges[0].Fill.SolidColor.Color = Color.Black; para.Alignment = TextAlignmentType.Left; } //save the document presentation.SaveToFile("PageProperty.pptx", FileFormat.Pptx2010); System.Diagnostics.Process.Start("PageProperty.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"); }