Exemplo n.º 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);
        }
Exemplo n.º 2
0
        public static void Run()
        {
            //ExStart:AddRelativeScaleHeightPictureFrame
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Shapes();

            // Instantiate presentation object
            using (Presentation presentation = new Presentation())
            {
                // Load Image to be added in presentaiton image collection
                Image    img   = new Bitmap(dataDir + "aspose-logo.jpg");
                IPPImage image = presentation.Images.AddImage(img);

                // Add picture frame to slide
                IPictureFrame pf = presentation.Slides[0].Shapes.AddPictureFrame(ShapeType.Rectangle, 50, 50, 100, 100, image);

                // Setting relative scale width and height
                pf.RelativeScaleHeight = 0.8f;
                pf.RelativeScaleWidth  = 1.35f;

                // Save presentation
                presentation.Save(dataDir + "Adding Picture Frame with Relative Scale_out.pptx", SaveFormat.Pptx);
            }
            //ExEnd:AddRelativeScaleHeightPictureFrame
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Slides_Presentations();

            //Instantiate the Presentation class that represents the presentation file

            using (Presentation pres = new Presentation(dataDir + "SetImageAsBackground.pptx"))
            {
                //Set the background with Image
                pres.Slides[0].Background.Type = BackgroundType.OwnBackground;
                pres.Slides[0].Background.FillFormat.FillType = FillType.Picture;
                pres.Slides[0].Background.FillFormat.PictureFillFormat.PictureFillMode = PictureFillMode.Stretch;

                //Set the picture
                System.Drawing.Image img = (System.Drawing.Image) new Bitmap(dataDir + "Tulips.jpg");

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

                pres.Slides[0].Background.FillFormat.PictureFillFormat.Picture.Image = imgx;

                //Write the presentation to disk
                pres.Save(dataDir + "ContentBG_Img.pptx", SaveFormat.Pptx);
            }
        }
Exemplo n.º 4
0
        public static void Run()
        {
            //ExStart:AddImageinsideTableCell
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Tables();

            // Instantiate Presentation class object
            Presentation presentation = new Presentation();

            // Access first slide
            ISlide islide = presentation.Slides[0];

            // Define columns with widths and rows with heights
            double[] dblCols = { 150, 150, 150, 150 };
            double[] dblRows = { 100, 100, 100, 100, 90 };

            // Add table shape to slide
            ITable tbl = islide.Shapes.AddTable(50, 50, dblCols, dblRows);

            // Creating a Bitmap Image object to hold the image file
            Bitmap image = new Bitmap(dataDir + "aspose-logo.jpg");

            // Create an IPPImage object using the bitmap object
            IPPImage imgx1 = presentation.Images.AddImage(image);

            // Add image to first table cell
            tbl[0, 0].CellFormat.FillFormat.FillType = FillType.Picture;
            tbl[0, 0].CellFormat.FillFormat.PictureFillFormat.PictureFillMode = PictureFillMode.Stretch;
            tbl[0, 0].CellFormat.FillFormat.PictureFillFormat.Picture.Image   = imgx1;

            // Save PPTX to Disk
            presentation.Save(dataDir + "Image_In_TableCell_out.pptx", SaveFormat.Pptx);
            //ExEnd:AddImageinsideTableCell
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            string FileName  = @"E:\Aspose\Aspose Vs VSTO\Aspose.Slides Vs VSTO Presentations v 1.1\Sample Files\Removing Row Or Column in Table.pptx";
            string ImageFile = @"E:\Aspose\Aspose Vs VSTO\Aspose.Slides Vs VSTO Presentations v 1.1\Sample Files\AsposeLogo.jpg";

            Presentation MyPresentation = new Presentation(FileName);

            //Get First Slide
            ISlide sld = MyPresentation.Slides[0];

            //Creating a Bitmap Image object to hold the image file
            System.Drawing.Bitmap image = new Bitmap(ImageFile);

            //Create an IPPImage object using the bitmap object
            IPPImage imgx1 = MyPresentation.Images.AddImage(image);

            foreach (IShape shp in sld.Shapes)
            {
                if (shp is ITable)
                {
                    ITable tbl = (ITable)shp;

                    //Add image to first table cell
                    tbl[0, 0].FillFormat.FillType = FillType.Picture;
                    tbl[0, 0].FillFormat.PictureFillFormat.PictureFillMode = PictureFillMode.Stretch;
                    tbl[0, 0].FillFormat.PictureFillFormat.Picture.Image   = imgx1;
                }
            }
            //Save PPTX to Disk
            MyPresentation.Save(FileName, Export.SaveFormat.Pptx);
        }
Exemplo n.º 6
0
        public static void Run()
        {
            //ExStart:SubstitutePictureTitleOfOLEObjectFrame
            // The path to the documents directory.
            string dataDir       = RunExamples.GetDataDir_Shapes();
            string oleSourceFile = dataDir + "ExcelObject.xlsx";
            string oleIconFile   = dataDir + "Image.png";

            using (Presentation pres = new Presentation())
            {
                IPPImage image = null;
                ISlide   slide = pres.Slides[0];

                // Add Ole objects
                byte[]          allbytes = File.ReadAllBytes(oleSourceFile);
                IOleObjectFrame oof      = slide.Shapes.AddOleObjectFrame(20, 20, 50, 50, "Excel.Sheet.12", allbytes);
                oof.IsObjectIcon = true;

                // Add image object
                byte[] imgBuf = File.ReadAllBytes(oleIconFile);
                using (MemoryStream ms = new MemoryStream(imgBuf))
                {
                    image = pres.Images.AddImage(new Bitmap(ms));
                }
                oof.SubstitutePictureFormat.Picture.Image = image;

                // Set caption to OLE icon
                oof.SubstitutePictureTitle = "Caption example";
            }

            //ExEnd:SubstitutePictureTitleOfOLEObjectFrame
        }
Exemplo n.º 7
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Charts();

            // Create an instance of Presentation class
            Presentation presentation = new Presentation();

            ISlide slide = presentation.Slides[0];

            // Creating the default chart
            IChart chart = slide.Shapes.AddChart(ChartType.LineWithMarkers, 0, 0, 400, 400);

            // Getting the default chart data worksheet index
            int defaultWorksheetIndex = 0;

            // Getting the chart data worksheet
            IChartDataWorkbook fact = chart.ChartData.ChartDataWorkbook;

            // Delete demo series
            chart.ChartData.Series.Clear();

            // Add new series
            chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 1, 1, "Series 1"), chart.Type);

            // Set the picture
            System.Drawing.Image image1 = (System.Drawing.Image) new Bitmap(dataDir + "aspose-logo.jpg");
            IPPImage             imgx1  = presentation.Images.AddImage(image1);

            // Set the picture
            System.Drawing.Image image2 = (System.Drawing.Image) new Bitmap(dataDir + "Tulips.jpg");
            IPPImage             imgx2  = presentation.Images.AddImage(image2);

            // Take first chart series
            IChartSeries series = chart.ChartData.Series[0];

            // Add new point (1:3) there.
            IChartDataPoint point = series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, 1, 1, (double)4.5));

            point.Marker.Format.Fill.FillType = FillType.Picture;
            point.Marker.Format.Fill.PictureFillFormat.Picture.Image = imgx1;

            point = series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, 2, 1, (double)2.5));
            point.Marker.Format.Fill.FillType = FillType.Picture;
            point.Marker.Format.Fill.PictureFillFormat.Picture.Image = imgx2;

            point = series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, 3, 1, (double)3.5));
            point.Marker.Format.Fill.FillType = FillType.Picture;
            point.Marker.Format.Fill.PictureFillFormat.Picture.Image = imgx1;

            point = series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, 4, 1, (double)4.5));
            point.Marker.Format.Fill.FillType = FillType.Picture;
            point.Marker.Format.Fill.PictureFillFormat.Picture.Image = imgx2;

            // Changing the chart series marker
            series.Marker.Size = 15;

            // Write presentation to disk
            presentation.Save(dataDir + "MarkOptions_out.pptx", SaveFormat.Pptx);
        }
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Shapes();

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

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

            //Instantiate Prseetation class that represents the PPTX
            using (Presentation pres = new Presentation())
            {
                //Get the first slide
                ISlide sld = pres.Slides[0];

                //Instantiate the ImageEx class
                System.Drawing.Image img  = (System.Drawing.Image) new Bitmap(dataDir + "aspose-logo.jpg");
                IPPImage             imgx = pres.Images.AddImage(img);

                //Add Picture Frame with height and width equivalent of Picture
                sld.Shapes.AddPictureFrame(ShapeType.Rectangle, 50, 150, imgx.Width, imgx.Height, imgx);

                //Write the PPTX file to disk
                pres.Save(dataDir + "RectPicFrame.pptx", SaveFormat.Pptx);
            }
        }
Exemplo n.º 9
0
        private void button1_Click(object sender, EventArgs e)
        {
            using (Presentation pres = new Presentation())
            {
                // Get the first slide
                pres.Slides.AddEmptySlide(pres.LayoutSlides[0]);
                pres.Slides.AddEmptySlide(pres.LayoutSlides[1]);
                ISlide sld1 = pres.Slides[0];
                ISlide sld2 = pres.Slides[1];
                ISlide sld3 = pres.Slides[2];

                // Instantiate the ImageEx class
                System.Drawing.Image img1  = (System.Drawing.Image) new Bitmap("1.jpg");
                System.Drawing.Image img2  = (System.Drawing.Image) new Bitmap("2.jpg");
                System.Drawing.Image img3  = (System.Drawing.Image) new Bitmap("3.jpg");
                IPPImage             imgx1 = pres.Images.AddImage(img1);
                IPPImage             imgx2 = pres.Images.AddImage(img2);
                IPPImage             imgx3 = pres.Images.AddImage(img3);

                // Add Picture Frame with height and width equivalent of Picture
                sld1.Shapes.AddPictureFrame(ShapeType.Rectangle, 0, 0, pres.SlideSize.Size.Width, pres.SlideSize.Size.Height, imgx1);
                sld2.Shapes.AddPictureFrame(ShapeType.Rectangle, 50, 50, imgx2.Width, imgx2.Height, imgx2);
                sld3.Shapes.AddPictureFrame(ShapeType.Rectangle, 100, 100, imgx3.Width, imgx3.Height, imgx3);

                // Apply some formatting to PictureFrameEx
                //pf.LineFormat.FillFormat.FillType = FillType.Solid;
                //pf.LineFormat.FillFormat.SolidFillColor.Color = Color.Blue;
                //pf.LineFormat.Width = 20;
                //pf.Rotation = 45;

                //Write the PPTX file to disk
                pres.Save("1.pptx", SaveFormat.Pptx);
            }
        }
Exemplo n.º 10
0
        public static void Run()
        {
            //ExStart:AddBlobImageToPresentation

            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_PresentationSaving();

            string pathToLargeImage = dataDir + "large_image.jpg";

            // create a new presentation which will contain this image
            using (Presentation pres = new Presentation())
            {
                using (FileStream fileStream = new FileStream(pathToLargeImage, FileMode.Open))
                {
                    // let's add the image to the presentation - we choose KeepLocked behavior, because we not
                    // have an intent to access the "largeImage.png" file.
                    IPPImage img = pres.Images.AddImage(fileStream, LoadingStreamBehavior.KeepLocked);
                    pres.Slides[0].Shapes.AddPictureFrame(ShapeType.Rectangle, 0, 0, 300, 200, img);

                    // save the presentation. Despite that the output presentation will be
                    // large, the memory consumption will be low the whole lifetime of the pres object
                    pres.Save(dataDir + "presentationWithLargeImage.pptx", SaveFormat.Pptx);
                }
            }

            //ExEnd:AddBlobImageToPresentation
        }
        public static void Run()
        {
            //ExStart:StretchOffsetLeftForPictureFrame
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Shapes();

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

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

            // Instantiate Prseetation class that represents the PPTX
            using (Presentation pres = new Presentation())
            {
                // Get the first slide
                ISlide slide = pres.Slides[0];

                // Instantiate the ImageEx class
                System.Drawing.Image img   = (System.Drawing.Image) new Bitmap(dataDir + "aspose-logo.jpg");
                IPPImage             imgEx = pres.Images.AddImage(img);

                // Add an AutoShape of Rectangle type
                IAutoShape aShape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 100, 100, 300, 300);

                // Set shape's fill type
                aShape.FillFormat.FillType = FillType.Picture;

                // Set shape's picture fill mode
                aShape.FillFormat.PictureFillFormat.PictureFillMode = PictureFillMode.Stretch;

                // Set image to fill the shape
                aShape.FillFormat.PictureFillFormat.Picture.Image = imgEx;

                // Specify image offsets from the corresponding edge of the shape's bounding box
                aShape.FillFormat.PictureFillFormat.StretchOffsetLeft   = 25;
                aShape.FillFormat.PictureFillFormat.StretchOffsetRight  = 25;
                aShape.FillFormat.PictureFillFormat.StretchOffsetTop    = -20;
                aShape.FillFormat.PictureFillFormat.StretchOffsetBottom = -10;


                //Write the PPTX file to disk
                pres.Save(dataDir + "StretchOffsetLeftForPictureFrame_out.pptx", SaveFormat.Pptx);
            }
            //ExEnd:StretchOffsetLeftForPictureFrame
        }
        public static Bitmap MetafileToBitmap(IPPImage image)
        {
            Metafile metafile = (Metafile)image.SystemImage;
            int      h        = metafile.Height;
            int      w        = metafile.Width;
            Bitmap   bitmap   = new Bitmap(w, h);

            using (Graphics g = Graphics.FromImage(bitmap))
            {
                g.Clear(Color.Transparent);
                g.SmoothingMode = SmoothingMode.None;
                g.DrawImage(metafile, 0, 0, w, h);
            }

            return(bitmap);
        }
Exemplo n.º 13
0
        static void Main(string[] args)
        {
            string ImageFilePath = @"E:\Aspose\Aspose Vs VSTO\Aspose.Slides Vs VSTO Presentations v 1.1\Sample Files\AddPicture.jpg";

            //Instantiate Prsentation class that represents the PPTX
            Presentation pres = new Presentation();

            //Get the first slide
            ISlide sld = pres.Slides[0];

            //Instantiate the ImageEx class
            Image    img  = (Image) new Bitmap(ImageFilePath);
            IPPImage imgx = pres.Images.AddImage(img);

            //Add Picture Frame with height and width equivalent of Picture
            sld.Shapes.AddPictureFrame(ShapeType.Rectangle, 50, 150, imgx.Width, imgx.Height, imgx);
        }
        public static void Run()
        {
            //ExStart:ManageParagraphPictureBulletsInPPT
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Text();

            Presentation presentation = new Presentation();

            // Accessing the first slide
            ISlide slide = presentation.Slides[0];

            // Instantiate the image for bullets
            Image    image     = new Bitmap(dataDir + "bullets.png");
            IPPImage ippxImage = presentation.Images.AddImage(image);

            // Adding and accessing Autoshape
            IAutoShape autoShape = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 200, 200, 400, 200);

            // Accessing the text frame of created autoshape
            ITextFrame textFrame = autoShape.TextFrame;

            // Removing the default exisiting paragraph
            textFrame.Paragraphs.RemoveAt(0);

            // Creating new paragraph
            Paragraph paragraph = new Paragraph();

            paragraph.Text = "Welcome to Aspose.Slides";

            // Setting paragraph bullet style and image
            paragraph.ParagraphFormat.Bullet.Type          = BulletType.Picture;
            paragraph.ParagraphFormat.Bullet.Picture.Image = ippxImage;

            // Setting Bullet Height
            paragraph.ParagraphFormat.Bullet.Height = 100;

            // Adding Paragraph to text frame
            textFrame.Paragraphs.Add(paragraph);

            // Writing the presentation as a PPTX file
            presentation.Save(dataDir + "ParagraphPictureBulletsPPTX_out.pptx", SaveFormat.Pptx);
            // Writing the presentation as a PPT file
            presentation.Save(dataDir + "ParagraphPictureBulletsPPT_out.ppt", SaveFormat.Ppt);
            //ExEnd:ManageParagraphPictureBulletsInPPT
        }
        public static void Run()
        {
            //ExStart:AddImageFromSVGObjectFromExternalResource
            // The path to the documents directory.
            string dataDir     = RunExamples.GetDataDir_PresentationSaving();
            string outPptxPath = dataDir + "presentation_external.pptx";

            using (var p = new Presentation())
            {
                string    svgContent = File.ReadAllText(new Uri(new Uri(dataDir), "image1.svg").AbsolutePath);
                ISvgImage svgImage   = new SvgImage(svgContent, new ExternalResourceResolver(), dataDir);
                IPPImage  ppImage    = p.Images.AddImage(svgImage);
                p.Slides[0].Shapes.AddPictureFrame(ShapeType.Rectangle, 0, 0, ppImage.Width, ppImage.Height, ppImage);
                p.Save(outPptxPath, SaveFormat.Pptx);
            }

            //ExEnd:AddImageFromSVGObjectFromExternalResource
        }
        public static string GetImageURL <T>(IPPImage image, TemplateContext <T> model)
        {
            string result = "";

            if (!model.Global.Get <bool>("embedImages"))
            {
                var imgSrcPath = model.Output.GetResourcePath(image);
                var slidesPath = model.Global.Get <string>("slidesPath");

                result = ShapeHelper.ConvertPathToRelative(imgSrcPath, slidesPath);
            }
            else
            {
                result = "data:image/png;base64, " + Convert.ToBase64String(image.BinaryData);
            }

            return(result);
        }
Exemplo n.º 17
0
        public static void Run()
        {
            //ExStart:AddImageFromSVGObject
            // The path to the documents directory.
            string dataDir     = RunExamples.GetDataDir_PresentationSaving();
            string svgPath     = dataDir + "sample.svg";
            string outPptxPath = dataDir + "presentation.pptx";

            using (var p = new Presentation())
            {
                string    svgContent = File.ReadAllText(svgPath);
                ISvgImage svgImage   = new SvgImage(svgContent);
                IPPImage  ppImage    = p.Images.AddImage(svgImage);
                p.Slides[0].Shapes.AddPictureFrame(ShapeType.Rectangle, 0, 0, ppImage.Width, ppImage.Height, ppImage);
                p.Save(outPptxPath, SaveFormat.Pptx);
            }

            //ExEnd:AddImageFromSVGObject
        }
        public static void Run()
        {
            //ExStart:FillShapesPicture
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Shapes();

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

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

            // Instantiate PrseetationEx class that represents the PPTX
            using (Presentation pres = new Presentation())
            {
                // Get the first slide
                ISlide sld = pres.Slides[0];

                // Add autoshape of rectangle type
                IShape shp = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 50, 150, 75, 150);


                // Set the fill type to Picture
                shp.FillFormat.FillType = FillType.Picture;

                // Set the picture fill mode
                shp.FillFormat.PictureFillFormat.PictureFillMode = PictureFillMode.Tile;

                // Set the picture
                System.Drawing.Image img  = (System.Drawing.Image) new Bitmap(dataDir + "Tulips.jpg");
                IPPImage             imgx = pres.Images.AddImage(img);
                shp.FillFormat.PictureFillFormat.Picture.Image = imgx;

                //Write the PPTX file to disk
                pres.Save(dataDir + "RectShpPic_out.pptx", SaveFormat.Pptx);
                //ExEnd:FillShapesPicture
            }
        }
Exemplo n.º 19
0
        public static void Run()
        {
            //ExStart:AddingEMZImagesToImageCollection
            // The path to the documents directory.
            string       dataDir = RunExamples.GetDataDir_PresentationProperties();
            Presentation p       = new Presentation();
            ISlide       s       = p.Slides[0];
            // byte[] buffer=new byte();
            String imagePath = @"C:\Aspose Data\emf files\";

            byte[] data = GetCompressedData(imagePath + "2.emz");
            if (s != null)
            {
                if (s.Shapes != null)
                {
                    IPPImage imgx = p.Images.AddImage(data);

                    var m = s.Shapes.AddPictureFrame(ShapeType.Rectangle, 0, 0, p.SlideSize.Size.Width, p.SlideSize.Size.Height, imgx);
                    p.Save("C:\\Asopse Data\\Saved.pptx", SaveFormat.Pptx);
                }
            }
        }
        public static void Run()
        {
            //ExStart:PictureFrameFormatting
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Shapes();

            // 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 PPTX
            using (Presentation pres = new Presentation())
            {
                // Get the first slide
                ISlide sld = pres.Slides[0];

                // Instantiate the ImageEx class
                System.Drawing.Image img  = (System.Drawing.Image) new Bitmap(dataDir + "aspose-logo.jpg");
                IPPImage             imgx = pres.Images.AddImage(img);

                // Add Picture Frame with height and width equivalent of Picture
                IPictureFrame pf = sld.Shapes.AddPictureFrame(ShapeType.Rectangle, 50, 150, imgx.Width, imgx.Height, imgx);

                // Apply some formatting to PictureFrameEx
                pf.LineFormat.FillFormat.FillType             = FillType.Solid;
                pf.LineFormat.FillFormat.SolidFillColor.Color = Color.Blue;
                pf.LineFormat.Width = 20;
                pf.Rotation         = 45;

                //Write the PPTX file to disk
                pres.Save(dataDir + "RectPicFrameFormat_out.pptx", SaveFormat.Pptx);
            }
            //ExEnd:PictureFrameFormatting
        }
        public static void Run()
        {
            //ExStart:BulletFillFormat
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_SmartArts();

            using (Presentation presentation = new Presentation())
            {
                ISmartArt     smart = presentation.Slides[0].Shapes.AddSmartArt(10, 10, 500, 400, SmartArtLayoutType.VerticalPictureList);
                ISmartArtNode node  = smart.AllNodes[0];

                if (node.BulletFillFormat != null)
                {
                    Image    img   = (Image) new Bitmap(dataDir + "aspose-logo.jpg");
                    IPPImage image = presentation.Images.AddImage(img);
                    node.BulletFillFormat.FillType = FillType.Picture;
                    node.BulletFillFormat.PictureFillFormat.Picture.Image   = image;
                    node.BulletFillFormat.PictureFillFormat.PictureFillMode = PictureFillMode.Stretch;
                }
                presentation.Save(dataDir + "out.pptx", SaveFormat.Pptx);
            }
            //ExEnd:BulletFillFormat
        }
        public static void AddImagesOutput(this WebDocument document, string outputPath, Presentation pres)
        {
            for (int index = 0; index < pres.Images.Count; index++)
            {
                IPPImage image = pres.Images[index];
                string   path;
                string   ext;

                if (image.ContentType == "image/x-emf" || image.ContentType == "image/x-wmf") // Output will convert metafiles to png
                {
                    ext = "png";
                }
                else
                {
                    ext = MimeTypesMap.GetExtension(image.ContentType);
                }

                path = Path.Combine(outputPath, string.Format("image{0}.{1}", index, ext));

                var outputFile = document.Output.Add(path, image);
                document.Output.BindResource(outputFile, image);
            }
        }
Exemplo n.º 23
0
        static void Main(string[] args)
        {
            MainAsync(args).Wait();
            string       path     = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName.ToString(); // Directory Path
            string       JsonData = File.ReadAllText(Path.GetFullPath(path) + "\\Json\\project.json");               //for temporary usage ..for production mainasync method will be used for fetching data
            ProjectModel pmodel   = new ProjectModel();

            pmodel = JsonConvert.DeserializeObject <ProjectModel>(JsonData);
            //Instantiate Prsentation class that represents the PPTX
            Presentation pres = new Presentation();
            //Get the first slide

            string currentDir = Path.GetFullPath(path) + "\\pptFolder\\";
            ISlide sld        = pres.Slides[0];

            sld.Name = "Existing Tender";
            //formatting Text
            PortionFormat portionFormat = new PortionFormat();

            portionFormat.FontHeight = 10;
            ProjectSummary.Logo();

            #region Border
            IAutoShape borderLines = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 3, 3, 715, 535);
            borderLines.FillFormat.FillType             = FillType.NoFill;
            borderLines.FillFormat.SolidFillColor.Color = Color.Black;
            #endregion

            #region Background

            //Add some text
            IAutoShape ashp = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 10, 10, 350, 20);
            //ashp.FillFormat.FillType = FillType.NoFill;
            //ashp.LineFormat.FillFormat.FillType = FillType.NoFill;
            // Add TextFrame to the Rectangle
            ashp.AddTextFrame(" ");
            ashp.FillFormat.SolidFillColor.Color = Color.DarkCyan;
            // 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 = "Background";
            portion.PortionFormat.FillFormat.FillType             = FillType.Solid;
            portion.PortionFormat.FillFormat.SolidFillColor.Color = Color.White;
            portion.PortionFormat.FontBold = NullableBool.True;


            #region Table 1
            double[] dblCols1 = { 60, 100, 190 };
            double[] dblRows1 = { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 };

            ITable tb1 = sld.Shapes.AddTable(10, 40, dblCols1, dblRows1);

            for (int i = 0; i < tb1.Rows.Count; i++)
            {
                for (int j = 0; j < tb1.Rows[i].Count; j++)
                {
                    //adding border to each cell of the table
                    tb1[j, i].BorderTop.FillFormat.FillType             = FillType.Solid;
                    tb1[j, i].BorderTop.FillFormat.SolidFillColor.Color = Color.Black;
                    tb1[j, i].BorderTop.Width = 1;

                    tb1[j, i].BorderBottom.FillFormat.FillType             = FillType.Solid;
                    tb1[j, i].BorderBottom.FillFormat.SolidFillColor.Color = Color.Black;
                    tb1[j, i].BorderBottom.Width = 1;

                    tb1[j, i].BorderLeft.FillFormat.FillType             = FillType.Solid;
                    tb1[j, i].BorderLeft.FillFormat.SolidFillColor.Color = Color.Black;
                    tb1[j, i].BorderLeft.Width = 1;

                    tb1[j, i].BorderRight.FillFormat.FillType             = FillType.Solid;
                    tb1[j, i].BorderRight.FillFormat.SolidFillColor.Color = Color.Black;
                    tb1[j, i].BorderRight.Width = 1;
                    //cell with white background
                    tb1[j, i].FillFormat.FillType             = FillType.Solid;
                    tb1[j, i].FillFormat.SolidFillColor.Color = Color.White;

                    //Grey color for first column
                    if (j == 0)
                    {
                        tb1[j, i].FillFormat.FillType             = FillType.Solid;
                        tb1[j, i].FillFormat.SolidFillColor.Color = Color.Gray;
                    }

                    //for 7th to last custom row
                    if (i >= 7)
                    {
                        tb1[j, i].BorderLeft.FillFormat.FillType             = FillType.Solid;
                        tb1[j, i].BorderLeft.FillFormat.SolidFillColor.Color = Color.White;
                        tb1[j, i].BorderLeft.Width = 1;

                        tb1[j, i].BorderBottom.FillFormat.FillType             = FillType.Solid;
                        tb1[j, i].BorderBottom.FillFormat.SolidFillColor.Color = Color.White;
                        tb1[j, i].BorderBottom.Width = 1;

                        tb1[j, i].BorderRight.FillFormat.FillType             = FillType.Solid;
                        tb1[j, i].BorderRight.FillFormat.SolidFillColor.Color = Color.White;
                        tb1[j, i].BorderRight.Width                         = 1;
                        tb1[j, i].BorderTop.FillFormat.FillType             = FillType.Solid;
                        tb1[j, i].BorderTop.FillFormat.SolidFillColor.Color = Color.White;
                        tb1[j, i].BorderTop.Width = 1;
                        if (i == 7)
                        {
                            tb1[j, i].BorderTop.FillFormat.FillType             = FillType.Solid;
                            tb1[j, i].BorderTop.FillFormat.SolidFillColor.Color = Color.Black;
                            tb1[j, i].BorderTop.Width = 1;
                        }
                        if (j == 2)
                        {
                            tb1[j, i].BorderLeft.FillFormat.FillType             = FillType.Solid;
                            tb1[j, i].BorderLeft.FillFormat.SolidFillColor.Color = Color.Black;
                            tb1[j, i].BorderLeft.Width = 1;
                        }
                        if (j == 2)
                        {
                            tb1[j, i].BorderLeft.FillFormat.FillType             = FillType.Solid;
                            tb1[j, i].BorderLeft.FillFormat.SolidFillColor.Color = Color.Black;
                            tb1[j, i].BorderLeft.Width = 1;
                        }
                        tb1[j, i].FillFormat.FillType             = FillType.Solid;
                        tb1[j, i].FillFormat.SolidFillColor.Color = Color.White;
                    }
                }
            }

            tb1.SetTextFormat(portionFormat);

            Bitmap image = new Bitmap(currentDir + "imagelogo.jpg");
            // Create an IPPImage object using the bitmap object
            IPPImage imgx1 = pres.Images.AddImage(image);

            // Add image to column 2 table cell
            tb1[2, 0].FillFormat.FillType = FillType.Picture;
            tb1[2, 0].FillFormat.PictureFillFormat.PictureFillMode = PictureFillMode.Stretch;
            tb1[2, 0].FillFormat.PictureFillFormat.Picture.Image   = imgx1;


            tb1.MergeCells(tb1[2, 0], tb1[2, 1], false);
            tb1.MergeCells(tb1[2, 0], tb1[2, 2], false);
            tb1.MergeCells(tb1[2, 0], tb1[2, 3], false);
            tb1.MergeCells(tb1[2, 0], tb1[2, 4], false);
            tb1.MergeCells(tb1[2, 0], tb1[2, 5], false);
            tb1.MergeCells(tb1[2, 0], tb1[2, 6], false);
            tb1.MergeCells(tb1[2, 0], tb1[2, 7], false);
            tb1.MergeCells(tb1[2, 0], tb1[2, 8], false);
            tb1.MergeCells(tb1[2, 0], tb1[2, 9], false);

            #endregion
            //column Names:
            tb1[0, 0].TextFrame.Text = "ProjectName";
            tb1[0, 1].TextFrame.Text = "Country";
            tb1[0, 2].TextFrame.Text = "Region";
            tb1[0, 3].TextFrame.Text = "Mode";
            tb1[0, 4].TextFrame.Text = "Project Type";
            tb1[0, 5].TextFrame.Text = "Project Id";
            tb1[0, 6].TextFrame.Text = "Updated Date";

            //inserting values from project

            tb1[1, 0].TextFrame.Text = pmodel.ProjectName;
            tb1[1, 1].TextFrame.Text = pmodel.Country;
            tb1[1, 2].TextFrame.Text = pmodel.Region;
            tb1[1, 3].TextFrame.Text = Enum.GetName(typeof(EnumValue.Mode), pmodel.Mode);
            tb1[1, 4].TextFrame.Text = Enum.GetName(typeof(EnumValue.TenderStatus), pmodel.DealStatus);
            tb1[1, 5].TextFrame.Text = pmodel.ProjectId;
            tb1[1, 6].TextFrame.Text = "7/09/2017";



            #region Table 2

            double[] coltbl2 = { 350 };
            double[] rowtbl2 = { 20, 50, 20, 50 };
            ITable   tb2     = sld.Shapes.AddTable(10, 230, coltbl2, rowtbl2);

            for (int i = 0; i < tb2.Rows.Count; i++)
            {
                for (int j = 0; j < tb2.Rows[i].Count; j++)
                {
                    //border for each cell
                    tb2[j, i].BorderTop.FillFormat.FillType             = FillType.Solid;
                    tb2[j, i].BorderTop.FillFormat.SolidFillColor.Color = Color.Black;
                    tb2[j, i].BorderTop.Width = 1;

                    tb2[j, i].BorderBottom.FillFormat.FillType             = FillType.Solid;
                    tb2[j, i].BorderBottom.FillFormat.SolidFillColor.Color = Color.Black;
                    tb2[j, i].BorderBottom.Width = 1;

                    tb2[j, i].BorderLeft.FillFormat.FillType             = FillType.Solid;
                    tb2[j, i].BorderLeft.FillFormat.SolidFillColor.Color = Color.Black;
                    tb2[j, i].BorderLeft.Width = 1;

                    tb2[j, i].BorderRight.FillFormat.FillType             = FillType.Solid;
                    tb2[j, i].BorderRight.FillFormat.SolidFillColor.Color = Color.Black;
                    tb2[j, i].BorderRight.Width = 1;

                    tb2[j, i].FillFormat.FillType = FillType.Solid;
                    if (i % 2 == 0)
                    {
                        tb2[j, i].FillFormat.SolidFillColor.Color = Color.Gray;
                    }
                    else
                    {
                        tb2[j, i].FillFormat.SolidFillColor.Color = Color.White;
                    }
                }
            }

            //Text Entry
            tb2[0, 0].TextFrame.Text = "Description";
            tb2[0, 1].TextFrame.Text = pmodel.Description;
            tb2[0, 2].TextFrame.Text = "Strategic Rationale";
            tb2[0, 3].TextFrame.Text = pmodel.StrategicRationale;
            tb2.SetTextFormat(portionFormat);

            #endregion

            #region Table 3
            // Table 3a

            double[] coltbl3a = { 40, 40, 40, 40 };
            double[] rowtbl3a = { 10, 10, 10, 10, 10 };
            ITable   tb3a     = sld.Shapes.AddTable(10, 400, coltbl3a, rowtbl3a);

            portionFormat.FontHeight = 10;
            tb3a.SetTextFormat(portionFormat);
            for (int i = 0; i < tb3a.Rows.Count; i++)
            {
                for (int j = 0; j < tb3a.Rows[i].Count; j++)
                {
                    tb3a[j, i].FillFormat.FillType = FillType.Solid;
                    if (i == 0 && j == 0)
                    {
                        tb3a[j, i].FillFormat.FillType = FillType.NoFill;
                    }
                    else
                    {
                        if ((i == 0 && j > 0) || (j == 0 && i > 0))
                        {
                            tb3a[j, i].FillFormat.SolidFillColor.Color = Color.Gray;
                        }
                        else
                        {
                            tb3a[j, i].FillFormat.SolidFillColor.Color = Color.White;
                        }
                        //border for each cell
                        tb3a[j, i].BorderTop.FillFormat.FillType             = FillType.Solid;
                        tb3a[j, i].BorderTop.FillFormat.SolidFillColor.Color = Color.Black;
                        tb3a[j, i].BorderTop.Width = 1;

                        tb3a[j, i].BorderBottom.FillFormat.FillType             = FillType.Solid;
                        tb3a[j, i].BorderBottom.FillFormat.SolidFillColor.Color = Color.Black;
                        tb3a[j, i].BorderBottom.Width = 1;

                        tb3a[j, i].BorderLeft.FillFormat.FillType             = FillType.Solid;
                        tb3a[j, i].BorderLeft.FillFormat.SolidFillColor.Color = Color.Black;
                        tb3a[j, i].BorderLeft.Width = 1;

                        tb3a[j, i].BorderRight.FillFormat.FillType             = FillType.Solid;
                        tb3a[j, i].BorderRight.FillFormat.SolidFillColor.Color = Color.Black;
                        tb3a[j, i].BorderRight.Width = 1;
                    }
                }
            }
            //column names:
            tb3a[1, 0].TextFrame.Text = "2017";
            tb3a[2, 0].TextFrame.Text = "2018";
            tb3a[3, 0].TextFrame.Text = "2019";
            tb3a[0, 1].TextFrame.Text = "Revenue";
            tb3a[0, 2].TextFrame.Text = "EBIT";
            tb3a[0, 3].TextFrame.Text = "Capex";
            tb3a[0, 4].TextFrame.Text = "MTP";

            tb3a[1, 1].TextFrame.Text = pmodel.RevenueX.ToString();
            tb3a[2, 1].TextFrame.Text = pmodel.RevenueX1.ToString();
            tb3a[3, 1].TextFrame.Text = pmodel.RevenueX2.ToString();

            tb3a[1, 2].TextFrame.Text = pmodel.EbitX.ToString();
            tb3a[2, 2].TextFrame.Text = pmodel.EbitX1.ToString();
            tb3a[3, 2].TextFrame.Text = pmodel.EbitX2.ToString();

            tb3a[1, 3].TextFrame.Text = pmodel.CAPEXXMEuro.ToString();
            tb3a[2, 3].TextFrame.Text = pmodel.CAPEX1MEuro.ToString();
            tb3a[3, 3].TextFrame.Text = pmodel.CAPEX2MEuro.ToString();
            // Table 3b
            double[] coltbl3b = { 100, 50 };
            double[] rowtbl3b = { 10, 10, 10 };
            ITable   tb3b     = sld.Shapes.AddTable(200, 400, coltbl3b, rowtbl3b);

            portionFormat.FontHeight = 10;
            tb3b.SetTextFormat(portionFormat);
            for (int i = 0; i < tb3b.Rows.Count; i++)
            {
                for (int j = 0; j < tb3b.Rows[i].Count; j++)
                {
                    tb3b[j, i].FillFormat.FillType = FillType.Solid;

                    if (j == 0)
                    {
                        tb3b[j, i].FillFormat.SolidFillColor.Color = Color.Gray;
                    }
                    else
                    {
                        tb3b[j, i].FillFormat.SolidFillColor.Color = Color.White;
                    }
                    //border for each cell
                    tb3b[j, i].BorderTop.FillFormat.FillType             = FillType.Solid;
                    tb3b[j, i].BorderTop.FillFormat.SolidFillColor.Color = Color.Black;
                    tb3b[j, i].BorderTop.Width = 1;

                    tb3b[j, i].BorderBottom.FillFormat.FillType             = FillType.Solid;
                    tb3b[j, i].BorderBottom.FillFormat.SolidFillColor.Color = Color.Black;
                    tb3b[j, i].BorderBottom.Width = 1;

                    tb3b[j, i].BorderLeft.FillFormat.FillType             = FillType.Solid;
                    tb3b[j, i].BorderLeft.FillFormat.SolidFillColor.Color = Color.Black;
                    tb3b[j, i].BorderLeft.Width = 1;

                    tb3b[j, i].BorderRight.FillFormat.FillType             = FillType.Solid;
                    tb3b[j, i].BorderRight.FillFormat.SolidFillColor.Color = Color.Black;
                    tb3b[j, i].BorderRight.Width = 1;
                }
            }


            //columns name
            tb3b[0, 0].TextFrame.Text = "EBIT";
            tb3b[0, 1].TextFrame.Text = "Number of vehicles";
            tb3b[0, 2].TextFrame.Text = "Contract Length";

            tb3b[0, 0].TextFrame.Text = pmodel.New_or_existingwork.ToString();
            tb3b[0, 1].TextFrame.Text = pmodel.NumberOfVehicles.ToString();
            tb3b[0, 2].TextFrame.Text = pmodel.CoreContractLength.ToString();



            #endregion

            #endregion

            #region Status

            //Add some text
            IAutoShape ashp1 = sld.Shapes.AddAutoShape(ShapeType.Rectangle, 400, 10, 300, 20);

            // Add TextFrame to the Rectangle
            ashp1.AddTextFrame("");
            ashp1.FillFormat.SolidFillColor.Color = Color.DarkCyan;
            // Accessing the text frame
            ITextFrame txtFrame1 = ashp1.TextFrame;


            // Create the Paragraph object for text frame
            IParagraph para1 = txtFrame1.Paragraphs[0];
            // Create Portion object for paragraph
            IPortion portion1 = para1.Portions[0];
            // Set Text
            portion1.Text = "Status";
            portion1.PortionFormat.FillFormat.FillType             = FillType.Solid;
            portion1.PortionFormat.FillFormat.SolidFillColor.Color = Color.White;
            portion1.PortionFormat.FontBold = NullableBool.True;

            #region Table 4
            //Define columns with widths and rows with heights
            //double[] dblCols = { 50, 50, 50 };
            double[] dblCols = { 80, 100, 60, 60 };
            double[] dblRows = { 20, 20, 20, 20, 40, 30 };

            //Add table shape to slide

            ITable tb4 = sld.Shapes.AddTable(400, 40, dblCols, dblRows);
            tb4.SetTextFormat(portionFormat);
            for (int i = 0; i < tb4.Rows.Count; i++)
            {
                for (int j = 0; j < tb4.Rows[i].Count; j++)
                {
                    //adding border to each cell of the table
                    tb4[j, i].BorderTop.FillFormat.FillType             = FillType.Solid;
                    tb4[j, i].BorderTop.FillFormat.SolidFillColor.Color = Color.Black;
                    tb4[j, i].BorderTop.Width = 1;

                    tb4[j, i].BorderBottom.FillFormat.FillType             = FillType.Solid;
                    tb4[j, i].BorderBottom.FillFormat.SolidFillColor.Color = Color.Black;
                    tb4[j, i].BorderBottom.Width = 1;

                    tb4[j, i].BorderLeft.FillFormat.FillType             = FillType.Solid;
                    tb4[j, i].BorderLeft.FillFormat.SolidFillColor.Color = Color.Black;
                    tb4[j, i].BorderLeft.Width = 1;

                    tb4[j, i].BorderRight.FillFormat.FillType             = FillType.Solid;
                    tb4[j, i].BorderRight.FillFormat.SolidFillColor.Color = Color.Black;
                    tb4[j, i].BorderRight.Width = 1;
                    //cell with white background
                    tb4[j, i].FillFormat.FillType             = FillType.Solid;
                    tb4[j, i].FillFormat.SolidFillColor.Color = Color.White;

                    //Grey color for first column
                    if (j == 0)
                    {
                        tb4[j, i].FillFormat.FillType             = FillType.Solid;
                        tb4[j, i].FillFormat.SolidFillColor.Color = Color.Gray;
                    }
                }
            }

            //color for cell
            //caution: color it before split otherwise left portion of split cell will be coloured
            tb4[3, 5].FillFormat.FillType             = FillType.Solid;
            tb4[3, 5].FillFormat.SolidFillColor.Color = Color.ForestGreen;
            tb4.SetTextFormat(portionFormat);


            //Set border format for each cell
            //Merge cells 1 & 2 of row 1
            tb4.MergeCells(tb4[1, 4], tb4[2, 4], false);
            tb4.MergeCells(tb4[2, 4], tb4[3, 4], false);
            tb4.MergeCells(tb4[1, 5], tb4[2, 5], false);
            tb4[3, 5].SplitByWidth(tb4[3, 5].Width / 2);
            tb4.MergeCells(tb4[2, 5], tb4[3, 5], false);
            //  tb4[1, 4].TextFrame.Text = "";



            //column names:

            tb4[0, 0].TextFrame.Text = "Division Responsible";
            tb4[0, 1].TextFrame.Text = "Executive Board Member";
            tb4[0, 2].TextFrame.Text = "Country Manager";
            tb4[0, 3].TextFrame.Text = "Project Manager";
            tb4[0, 4].TextFrame.Text = "Team Members(and role) OR requirements";
            tb4[0, 5].TextFrame.Text = "Uncovered Team Resources";
            tb4[2, 0].TextFrame.Text = "Contract Type";
            tb4[2, 1].TextFrame.Text = "Project Stage";
            tb4[2, 2].TextFrame.Text = "Type";
            tb4[2, 3].TextFrame.Text = "Probability";

            //project values:
            tb4[1, 0].TextFrame.Text = pmodel.AdditionalTeamMembers;
            tb4[1, 1].TextFrame.Text = pmodel.ExecutiveBoardMember;
            tb4[1, 2].TextFrame.Text = pmodel.CountryManager;
            tb4[1, 3].TextFrame.Text = pmodel.ProjectManager;
            tb4[1, 4].TextFrame.Text = pmodel.UncoveredTeamResources;
            tb4[2, 0].TextFrame.Text = Enum.GetName(typeof(EnumValue.ContractType), pmodel.ContractType);
            tb4[2, 1].TextFrame.Text = Enum.GetName(typeof(EnumValue.ContractType), pmodel.ProjectStageTender);
            tb4[2, 2].TextFrame.Text = "A(>500)";
            tb4[2, 3].TextFrame.Text = "60%";

            #endregion

            #region Table 5

            double[] dblCols5 = { 80, 160, 30, 30 };
            double[] dblRows5 = { 10, 10, 10, 10, 10, 10, 10, 10, 10 };
            ITable   tb5      = sld.Shapes.AddTable(400, 200, dblCols5, dblRows5);
            for (int i = 0; i < tb5.Rows.Count; i++)
            {
                for (int j = 0; j < tb5.Rows[i].Count; j++)
                {
                    //adding border to each cell of the table
                    tb5[j, i].BorderTop.FillFormat.FillType             = FillType.Solid;
                    tb5[j, i].BorderTop.FillFormat.SolidFillColor.Color = Color.Black;
                    tb5[j, i].BorderTop.Width = 1;

                    tb5[j, i].BorderBottom.FillFormat.FillType             = FillType.Solid;
                    tb5[j, i].BorderBottom.FillFormat.SolidFillColor.Color = Color.Black;
                    tb5[j, i].BorderBottom.Width = 1;

                    tb5[j, i].BorderLeft.FillFormat.FillType             = FillType.Solid;
                    tb5[j, i].BorderLeft.FillFormat.SolidFillColor.Color = Color.Black;
                    tb5[j, i].BorderLeft.Width = 1;

                    tb5[j, i].BorderRight.FillFormat.FillType             = FillType.Solid;
                    tb5[j, i].BorderRight.FillFormat.SolidFillColor.Color = Color.Black;
                    tb5[j, i].BorderRight.Width = 1;
                    //cell with white background
                    tb5[j, i].FillFormat.FillType             = FillType.Solid;
                    tb5[j, i].FillFormat.SolidFillColor.Color = Color.White;

                    //Grey color for first column
                    if (i < 2 || j == 3)
                    {
                        tb5[j, i].FillFormat.FillType             = FillType.Solid;
                        tb5[j, i].FillFormat.SolidFillColor.Color = Color.Gray;
                    }
                }
            }
            tb5.SetTextFormat(portionFormat);

            //column names:
            tb5[0, 0].TextFrame.Text = "KeyMilestone & Action";
            tb5[0, 1].TextFrame.Text = "Date";
            tb5[1, 1].TextFrame.Text = "Task/Event";
            tb5[2, 1].TextFrame.Text = "Resp";
            tb5[3, 1].TextFrame.Text = "Status";
            for (int i = 2; i <= pmodel.KeyMileStoneAndAction.Count + 1; i++)
            {
                tb5[0, i].TextFrame.Text = pmodel.KeyMileStoneAndAction[i - 2].Date;
                tb5[1, i].TextFrame.Text = pmodel.KeyMileStoneAndAction[i - 2].TaskEvent;
                tb5[2, i].TextFrame.Text = pmodel.KeyMileStoneAndAction[i - 2].Resp;
                tb5[3, i].TextFrame.Text = pmodel.KeyMileStoneAndAction[i - 2].Status;
            }

            #endregion

            #region Table 6
            double[] dblCols6 = { 300 };
            double[] dblRows6 = { 20, 40 };

            ITable tb6 = sld.Shapes.AddTable(400, 380, dblCols6, dblRows6);
            tb6.SetTextFormat(portionFormat);
            for (int i = 0; i < tb6.Rows.Count; i++)
            {
                for (int j = 0; j < tb6.Rows[i].Count; j++)
                {
                    //adding border to each cell of the table
                    tb6[j, i].BorderTop.FillFormat.FillType             = FillType.Solid;
                    tb6[j, i].BorderTop.FillFormat.SolidFillColor.Color = Color.Black;
                    tb6[j, i].BorderTop.Width = 1;

                    tb6[j, i].BorderBottom.FillFormat.FillType             = FillType.Solid;
                    tb6[j, i].BorderBottom.FillFormat.SolidFillColor.Color = Color.Black;
                    tb6[j, i].BorderBottom.Width = 1;

                    tb6[j, i].BorderLeft.FillFormat.FillType             = FillType.Solid;
                    tb6[j, i].BorderLeft.FillFormat.SolidFillColor.Color = Color.Black;
                    tb6[j, i].BorderLeft.Width = 1;

                    tb6[j, i].BorderRight.FillFormat.FillType             = FillType.Solid;
                    tb6[j, i].BorderRight.FillFormat.SolidFillColor.Color = Color.Black;
                    tb6[j, i].BorderRight.Width = 1;
                    //cell with white background
                    tb6[j, i].FillFormat.FillType             = FillType.Solid;
                    tb6[j, i].FillFormat.SolidFillColor.Color = Color.White;

                    //Grey color for first column
                    if (i == 0 && j == 0)
                    {
                        tb6[j, i].FillFormat.FillType             = FillType.Solid;
                        tb6[j, i].FillFormat.SolidFillColor.Color = Color.Gray;
                    }
                }
            }

            #endregion

            tb6[0, 0].TextFrame.Text = "Status Description";
            tb6[0, 1].TextFrame.Text = pmodel.StatusDescription;


            #region Table 7
            double[] dblCols7 = { 240, 30, 30 };
            double[] dblRows7 = { 20, 20, 20, 20 };

            ITable tb7 = sld.Shapes.AddTable(400, 445, dblCols7, dblRows7);
            tb7.SetTextFormat(portionFormat);
            for (int i = 0; i < tb7.Rows.Count; i++)
            {
                for (int j = 0; j < tb7.Rows[i].Count; j++)
                {
                    //adding border to each cell of the table
                    tb7[j, i].BorderTop.FillFormat.FillType             = FillType.Solid;
                    tb7[j, i].BorderTop.FillFormat.SolidFillColor.Color = Color.Black;
                    tb7[j, i].BorderTop.Width = 1;

                    tb7[j, i].BorderBottom.FillFormat.FillType             = FillType.Solid;
                    tb7[j, i].BorderBottom.FillFormat.SolidFillColor.Color = Color.Black;
                    tb7[j, i].BorderBottom.Width = 1;

                    tb7[j, i].BorderLeft.FillFormat.FillType             = FillType.Solid;
                    tb7[j, i].BorderLeft.FillFormat.SolidFillColor.Color = Color.Black;
                    tb7[j, i].BorderLeft.Width = 1;

                    tb7[j, i].BorderRight.FillFormat.FillType             = FillType.Solid;
                    tb7[j, i].BorderRight.FillFormat.SolidFillColor.Color = Color.Black;
                    tb7[j, i].BorderRight.Width = 1;
                    //cell with white background
                    tb7[j, i].FillFormat.FillType             = FillType.Solid;
                    tb7[j, i].FillFormat.SolidFillColor.Color = Color.White;

                    //Grey color for first column
                    if (i == 0)
                    {
                        tb7[j, i].FillFormat.FillType             = FillType.Solid;
                        tb7[j, i].FillFormat.SolidFillColor.Color = Color.Gray;
                    }
                }
            }

            #endregion
            tb7[0, 0].TextFrame.Text = "Issue For Discussion";
            for (int i = 1; i <= pmodel.Issues.Count; i++)
            {
                tb7[0, i].TextFrame.Text = pmodel.Issues[i - 1].Issues;
                tb7[1, i].TextFrame.Text = pmodel.Issues[i - 1].Owner;
                tb7[2, i].TextFrame.Text = pmodel.Issues[i - 1].Date;
            }


            #endregion

            #region projectsummary

            ProjectSummary.ProjSummary1(ref pres);

            #endregion

            #region Opportunities Schedule

            ProjectSummary.OpportunitiesSchedule(ref pres);


            #endregion


            Console.Write("ppt in progress");
            pres.Save(currentDir + "Table.pptx", Export.SaveFormat.Pptx);
        }
Exemplo n.º 24
0
 private void pdf_to_ppt(save_progress progress, System.Windows.Forms.Form dlg, string fileType)
 {
     try
     {
         Aspose.Pdf.Document document = null;
         int num = 0;
         if (fileType == ".pdf")
         {
             document = this.pdf_doc;
             num      = 0;
         }
         else if ((fileType == ".doc") || (fileType == ".docx"))
         {
             document = this.doc_to_pdf(progress, dlg, 0);
             num      = 50;
         }
         else if ((fileType == ".xls") || (fileType == ".xlsx"))
         {
             document = this.xls_to_pdf(progress, dlg, 0);
             num      = 50;
         }
         Presentation presentation = new Presentation();
         JpegDevice   device       = new JpegDevice(new Resolution(300), 100);
         if (progress != null)
         {
             dlg.Invoke(progress, new object[] { num });
         }
         int num3 = 0;
         for (int i = 1; num3 < document.Pages.Count; i++)
         {
             presentation.Slides.AddEmptySlide(presentation.LayoutSlides[0]);
             presentation.Slides[num3].Shapes.AddAutoShape(Aspose.Slides.ShapeType.Rectangle, 10f, 20f, (float)this.global_config.pic_width, (float)this.global_config.pic_height);
             int num2 = presentation.Slides[num3].Shapes.Count - 1;
             presentation.Slides[num3].Shapes[num2].FillFormat.FillType = FillType.Picture;
             presentation.Slides[num3].Shapes[num2].FillFormat.PictureFillFormat.PictureFillMode = PictureFillMode.Stretch;
             MemoryStream output = new MemoryStream();
             device.Process(document.Pages[i], output);
             IPPImage image = presentation.Images.AddImage(new Bitmap(output));
             presentation.Slides[num3].Shapes[num2].FillFormat.PictureFillFormat.Picture.Image = image;
             if (progress != null)
             {
                 if (num == 50)
                 {
                     dlg.Invoke(progress, new object[] { ((num3 * 50) / document.Pages.Count) + 50 });
                 }
                 else
                 {
                     dlg.Invoke(progress, new object[] { (num3 * 100) / document.Pages.Count });
                 }
             }
             num3++;
         }
         presentation.Save(this.global_config.target_dic + Path.GetFileNameWithoutExtension(this.file_path) + this.get_suffix(), Aspose.Slides.Export.SaveFormat.Ppt);
     }
     catch (Exception)
     {
         return;
     }
     if (progress != null)
     {
         dlg.Invoke(progress, new object[] { 100 });
     }
 }
        public static void Run()
        {
            //ExStart:ChartMarkerOptionsOnDataPoint
            string       dataDir = RunExamples.GetDataDir_Charts();
            Presentation pres    = new Presentation(dataDir + "Test.pptx");

            ISlide slide = pres.Slides[0];

            //Creating the default chart
            IChart chart = slide.Shapes.AddChart(ChartType.LineWithMarkers, 0, 0, 400, 400);

            //Getting the default chart data worksheet index
            int defaultWorksheetIndex = 0;

            //Getting the chart data worksheet
            IChartDataWorkbook fact = chart.ChartData.ChartDataWorkbook;

            //Delete demo series
            chart.ChartData.Series.Clear();

            //Add new series
            chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 1, 1, "Series 1"), chart.Type);

            String imagePath = @"C:\Users\Public\Pictures\Sample Pictures\";

            //Set the picture
            System.Drawing.Image img   = (System.Drawing.Image) new Bitmap(imagePath + "Desert.jpg");
            IPPImage             imgx1 = pres.Images.AddImage(img);

            //Set the picture
            System.Drawing.Image img2  = (System.Drawing.Image) new Bitmap(imagePath + "Tulips.jpg");
            IPPImage             imgx2 = pres.Images.AddImage(img2);

            //Take first chart series
            IChartSeries series = chart.ChartData.Series[0];

            //Add new point (1:3) there.
            IChartDataPoint point = series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, 1, 1, (double)4.5));

            point.Marker.Format.Fill.FillType = FillType.Picture;
            point.Marker.Format.Fill.PictureFillFormat.Picture.Image = imgx1;

            point = series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, 2, 1, (double)2.5));
            point.Marker.Format.Fill.FillType = FillType.Picture;
            point.Marker.Format.Fill.PictureFillFormat.Picture.Image = imgx2;


            point = series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, 3, 1, (double)3.5));
            point.Marker.Format.Fill.FillType = FillType.Picture;
            point.Marker.Format.Fill.PictureFillFormat.Picture.Image = imgx1;


            point = series.DataPoints.AddDataPointForLineSeries(fact.GetCell(defaultWorksheetIndex, 4, 1, (double)4.5));
            point.Marker.Format.Fill.FillType = FillType.Picture;
            point.Marker.Format.Fill.PictureFillFormat.Picture.Image = imgx2;


            //Changing the chart series marker
            series.Marker.Size = 15;

            pres.Save(dataDir + "AsposeScatterChart.pptx", SaveFormat.Pptx);
        }
        public static void Run()
        {
            string dataDir          = RunExamples.GetDataDir_Conversion();
            string presTemplatePath = Path.Combine(dataDir, "PresentationTemplate.pptx");
            string resultPath       = Path.Combine(RunExamples.OutPath, "MailMergeResult");

            // Path to the data.
            // XML data is one of the examples of the possible MailMerge data sources (among RDBMS and other types of data sources).
            string dataPath = Path.Combine(dataDir, "TestData.xml");

            // Check if result path exists
            if (!Directory.Exists(resultPath))
            {
                Directory.CreateDirectory(resultPath);
            }

            // Creating DataSet using XML data
            using (DataSet dataSet = new DataSet())
            {
                dataSet.ReadXml(dataPath);

                DataTableCollection dataTables     = dataSet.Tables;
                DataTable           usersTable     = dataTables["TestTable"];
                DataTable           staffListTable = dataTables["StaffList"];
                DataTable           planFactTable  = dataTables["Plan_Fact"];

                // For all records in main table we will create a separate presentation
                foreach (DataRow userRow in usersTable.Rows)
                {
                    // create result (individual) presentation name
                    string presPath = Path.Combine(resultPath, "PresFor_" + userRow["Name"] + ".pptx");

                    // Load presentation template
                    using (Presentation pres = new Presentation(presTemplatePath))
                    {
                        // Fill text boxes with data from data base main table
                        ((AutoShape)pres.Slides[0].Shapes[0]).TextFrame.Text =
                            "Chief of the department - " + userRow["Name"];
                        ((AutoShape)pres.Slides[0].Shapes[4]).TextFrame.Text = userRow["Department"].ToString();

                        // Get image from data base
                        byte[] bytes = Convert.FromBase64String(userRow["Img"].ToString());

                        // insert image into picture frame of presentation
                        IPPImage      image = pres.Images.AddImage(bytes);
                        IPictureFrame pf    = pres.Slides[0].Shapes[1] as PictureFrame;
                        pf.PictureFormat.Picture.Image.ReplaceImage(image);

                        // Get abd prepare text frame for filling it with datas
                        IAutoShape list      = pres.Slides[0].Shapes[2] as IAutoShape;
                        ITextFrame textFrame = list.TextFrame;

                        textFrame.Paragraphs.Clear();
                        Paragraph para = new Paragraph();
                        para.Text = "Department Staff:";
                        textFrame.Paragraphs.Add(para);

                        // fill staff data
                        FillStaffList(textFrame, userRow, staffListTable);

                        // fill plan fact data
                        FillPlanFact(pres, userRow, planFactTable);

                        pres.Save(presPath, SaveFormat.Pptx);
                    }
                }
            }
        }