|
| 1 | +using DocumentFormat.OpenXml; |
| 2 | +using PKG = DocumentFormat.OpenXml.Packaging; |
| 3 | +using P = DocumentFormat.OpenXml.Presentation; |
| 4 | +using System; |
| 5 | +using GeneratedCode; |
| 6 | +using FileFormat.Slides; |
| 7 | +using System.Collections.Generic; |
| 8 | +using FileFormat.Slides.Common; |
| 9 | + |
| 10 | +class Program |
| 11 | +{ |
| 12 | + static void Main () |
| 13 | + { |
| 14 | + /* Create new Presentation |
| 15 | + Presentation presentation = Presentation.Create("D:\\AsposeSampleResults\\test2.pptx"); |
| 16 | + TextShape shape = new TextShape(); |
| 17 | + shape.Text = "Title: Here is my first title From FF"; |
| 18 | + shape.TextColor = "980078"; |
| 19 | + shape.FontFamily = "Baguet Script"; |
| 20 | + TextShape shape2 = new TextShape(); |
| 21 | + shape2.Text = "Body : Here is my first title From FF"; |
| 22 | + shape2.FontFamily = "BIZ UDGothic"; |
| 23 | + shape2.FontSize = 3000; |
| 24 | + shape2.Y = Utility.EmuToPixels(2499619); |
| 25 | + // First slide |
| 26 | + Slide slide = new Slide(); |
| 27 | + slide.AddTextShapes(shape); |
| 28 | + slide.AddTextShapes(shape2); |
| 29 | + // 2nd slide |
| 30 | + Slide slide1 = new Slide(); |
| 31 | + slide1.AddTextShapes(shape); |
| 32 | + slide1.AddTextShapes(shape2); |
| 33 | + // Adding slides |
| 34 | + presentation.AppendSlide(slide); |
| 35 | + presentation.AppendSlide(slide1); |
| 36 | + presentation.Save();*/ |
| 37 | + |
| 38 | + /* Open and update a PPTX file |
| 39 | + Presentation presentation = Presentation.Open("D:\\AsposeSampleData\\sample.pptx"); |
| 40 | + var slides = presentation.GetSlides(); |
| 41 | + var slide = slides[3]; |
| 42 | + List<TextShape> shapes = slide.GetTextShapesByText("PRESENTATION"); |
| 43 | + var shape = slide.TextShapes[1]; |
| 44 | + //shape.X = 100000; |
| 45 | + //shape.Y = 100000; |
| 46 | + shape.Alignment= FileFormat.Slides.Common.Enumerations.TextAlignment.Left; |
| 47 | + shape.Text = "Muhammad Umar"; |
| 48 | + shape.Update(); |
| 49 | + presentation.Save(); |
| 50 | + */ |
| 51 | + |
| 52 | + /* |
| 53 | + * Remove a slide from presentation. |
| 54 | + Presentation presentation = Presentation.Open("D:\\AsposeSampleData\\sample.pptx"); |
| 55 | + var confirmation = presentation.RemoveSlide(0); |
| 56 | + Console.WriteLine(confirmation); |
| 57 | + presentation.Save(); |
| 58 | + */ |
| 59 | + |
| 60 | + /* |
| 61 | + * Remove text shape from a slide |
| 62 | + Presentation presentation = Presentation.Open("D:\\AsposeSampleData\\sample.pptx"); |
| 63 | + var slides = presentation.GetSlides(); |
| 64 | + var slide = slides[0]; |
| 65 | + var shape = slide.TextShapes[0]; |
| 66 | + shape.Remove(); |
| 67 | + presentation.Save(); |
| 68 | + */ |
| 69 | + |
| 70 | + |
| 71 | + /* |
| 72 | + * Add slide to an existing presentation |
| 73 | + Presentation presentation = Presentation.Open("D:\\AsposeSampleData\\sample.pptx"); |
| 74 | + TextShape shape1 = new TextShape(); |
| 75 | + shape1.Text = "Body : Here is my first title From FF"; |
| 76 | + shape1.FontFamily = "Baguet Script"; |
| 77 | + shape1.TextColor = Colors.Olive; |
| 78 | + shape1.FontSize = 45; |
| 79 | + shape1.Y = 10.0; |
| 80 | + // First slide |
| 81 | + Slide slide = new Slide(); |
| 82 | + Image image1 = new Image("D:\\AsposeSampleData\\target.png"); |
| 83 | + image1.X = Utility.EmuToPixels(1838700); |
| 84 | + image1.Y = Utility.EmuToPixels(1285962); |
| 85 | + image1.Width = Utility.EmuToPixels(2514600); |
| 86 | + image1.Height = Utility.EmuToPixels(2886075); |
| 87 | + slide.AddImage(image1); |
| 88 | + slide.AddTextShapes(shape1); |
| 89 | + presentation.AppendSlide(slide); |
| 90 | + presentation.Save(); |
| 91 | + */ |
| 92 | + |
| 93 | + /* |
| 94 | + * Update an image in a slide |
| 95 | + Presentation presentation = Presentation.Open("D:\\AsposeSampleData\\sample.pptx"); |
| 96 | + var slides = presentation.GetSlides(); |
| 97 | + var slide = slides[0]; |
| 98 | + List<Image> images = slide.Images; |
| 99 | + var image = slide.Images[0]; |
| 100 | + image.Width = 300.0; |
| 101 | + image.Height = 300.0; |
| 102 | + image.Update(); |
| 103 | + presentation.Save();*/ |
| 104 | + |
| 105 | + /* |
| 106 | + * Extract and save images of an existing PPTX |
| 107 | + Presentation presentation = Presentation.Open("D:\\AsposeSampleData\\sample.pptx"); |
| 108 | + presentation.ExtractAndSaveImages("testing images"); */ |
| 109 | + |
| 110 | + |
| 111 | + |
| 112 | + |
| 113 | + } |
| 114 | + |
| 115 | +} |
0 commit comments