Example #1
0
        private static void GenerateVideoFromAspose(string sourcePath, string extension)
        {
            var pptPresentation     = new Aspose.Slides.Presentation();
            ISlideCollection slides = pptPresentation.Slides;

            var dirInfo     = new DirectoryInfo(sourcePath);
            var jpgFileList = new List <string>();

            if (dirInfo.Exists)
            {
                jpgFileList.AddRange(dirInfo.GetFiles().Where(f => f.Extension.Equals(extension)).OrderBy(f => f.LastWriteTime).Take(3).Select(fileToUpload => sourcePath + "\\" + fileToUpload.Name));
            }

            //Aspose.Slides.Slide slide;
            for (int i = 0; i < jpgFileList.Count; i++)
            {
                var slide = slides.AddEmptySlide(pptPresentation.LayoutSlides[i + 1]);
                //Set the background with Image
                slide.Background.Type = BackgroundType.OwnBackground;
                slide.Background.FillFormat.FillType = FillType.Picture;
                slide.Background.FillFormat.PictureFillFormat.PictureFillMode = PictureFillMode.Stretch;

                //Set the picture
                var img = (System.Drawing.Image) new Bitmap(jpgFileList[i]);

                //Add image to presentation's images collection
                IPPImage imgx = pptPresentation.Images.AddImage(img);

                slide.Background.FillFormat.PictureFillFormat.Picture.Image = imgx;
            }

            //Save the PPTX file to the Disk
            pptPresentation.Save(sourcePath + "\\EmptySlide.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
        }
        public static void Run()
        {
            //ExStart:AddSlides
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Slides_Presentations_CRUD();

            // Create directory if it is not already present.
            bool IsExists = System.IO.Directory.Exists(dataDir);

            if (!IsExists)
            {
                System.IO.Directory.CreateDirectory(dataDir);
            }

            // Instantiate Presentation class that represents the presentation file
            using (Presentation pres = new Presentation())
            {
                // Instantiate SlideCollection calss
                ISlideCollection slds = pres.Slides;

                for (int i = 0; i < pres.LayoutSlides.Count; i++)
                {
                    // Add an empty slide to the Slides collection
                    slds.AddEmptySlide(pres.LayoutSlides[i]);
                }

                // Save the PPTX file to the Disk
                pres.Save(dataDir + "EmptySlide_out.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
            }
            //ExEnd:AddSlides
        }
        public static void CreatePresentation(string filepath)
        {
            //Instantiate a Presentation object that represents a PPT file
            using (Presentation pres = new Presentation())
            {
                //Instantiate SlideExCollection calss
                ISlideCollection slds = pres.Slides;

                //Add an empty slide to the SlidesEx collection
                slds.AddEmptySlide(pres.LayoutSlides[0]);

                //Save your presentation to a file
                pres.Save(filepath, Aspose.Slides.Export.SaveFormat.Pptx);
            }
        }
        public static void AddingSlidetoPresentation()
        {
            Presentation pres = new Presentation();

            //Instantiate SlideCollection class

            ISlideCollection slds = pres.Slides;

            for (int i = 0; i < pres.LayoutSlides.Count; i++)
            {
                //Add an empty slide to the Slides collection
                slds.AddEmptySlide(pres.LayoutSlides[i]);
            }

            //Save the PPTX file to the Disk
            pres.Save(MyDir + "Assemble Slides.pptx", SaveFormat.Pptx);
        }