Ejemplo n.º 1
0
 public Slide(ISlide slide)
 {
     this.id = slide.id;
     this.description = slide.description;
     this.date_updated = slide.date_updated;
     this.image_path = slide.image_path;
     this.alt_text = slide.alt_text;
     this.created_by = slide.created_by;
     this.updated_by = slide.updated_by;
 }
 // Method implementation to find a shape in a slide using its alternative text
 public static IShape FindShape(ISlide slide, string alttext)
 {
     // Iterating through all shapes inside the slide
     for (int i = 0; i < slide.Shapes.Count; i++)
     {
         // If the alternative text of the slide matches with the required one then
         // Return the shape
         if (slide.Shapes[i].AlternativeText.CompareTo(alttext) == 0)
             return slide.Shapes[i];
     }
     return null;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 竞品复地--第一个图表
        /// </summary>
        /// <param name="sld"></param>
        /// <param name="dt"></param>
        /// <param name="index"></param>
        public static void Chart_jp_fudi_chart1(ISlide sld, System.Data.DataTable dt, int index)
        {
            IChart t1 = (IChart)sld.Shapes[index];

            dt = dt.AsEnumerable().OrderByDescending(m => m["成交套数"]).CopyToDataTable();
            string range = "Sheet1!$A$1:$" + Base_ColumnsHelper.GET_INDEX(dt.Columns.Count) + "$" + (dt.Rows.Count + 1);

            //实例化图表数据表
            IChartDataWorkbook fact = t1.ChartData.ChartDataWorkbook;

            //t1.Axes.SecondaryVerticalAxis.IsAutomaticMajorUnit = true;
            //t1.Axes.SecondaryVerticalAxis.IsAutomaticMaxValue = true;
            //t1.Axes.SecondaryVerticalAxis.IsAutomaticMinorUnit = true;
            //t1.Axes.SecondaryVerticalAxis.IsAutomaticMinValue = true;

            t1.ChartData.ChartDataWorkbook.Clear(0);

            Workbook     workbook = Office_TableToWork.GetWorkBooxFromDataTable(dt);
            MemoryStream mem      = new MemoryStream();

            workbook.Save(mem, Aspose.Cells.SaveFormat.Xlsx);

            t1.ChartData.WriteWorkbookStream(mem);

            t1.ChartData.SetRange(range);

            ///第一列
            IChartSeries series = t1.ChartData.Series[0];

            series.Type = ChartType.ClusteredColumn;
            series.Labels.DefaultDataLabelFormat.ShowValue = true;
            series.Labels.DefaultDataLabelFormat.Position  = LegendDataLabelPosition.OutsideEnd;
            ///第二列
            IChartSeries series1 = t1.ChartData.Series[1];

            series1.PlotOnSecondAxis = true;
            series1.Type             = ChartType.StackedLineWithMarkers;
            series1.Labels.DefaultDataLabelFormat.ShowValue = true;
            series1.Labels.DefaultDataLabelFormat.Position  = LegendDataLabelPosition.Top;
        }
Ejemplo n.º 4
0
        public ActionResult Tables(string Browser)
        {
            //Creates a new instance of the presentation.
            IPresentation presentation = Presentation.Create();

            #region Slide1
            //To add a slide to PowerPoint presentation
            ISlide slide = presentation.Slides.Add(SlideLayoutType.TitleOnly);
            //To set the table title in a slide
            SetTableTitle(slide);
            //Get table data from xml file
            DataSet dataSet  = new DataSet();
            string  dataPath = ResolveApplicationDataPath("TableData.xml");
            dataSet.ReadXml(dataPath);
            int columnCount = dataSet.Tables[0].Rows.Count + 1;
            int rowCount    = dataSet.Tables.Count - 1;
            //To add a new table in slide.
            ITable table = slide.Shapes.AddTable(rowCount, columnCount, 61.92, 95.76, 856.8, 378.72);
            //To set the style for the table.
            table.BuiltInStyle = BuiltInTableStyle.MediumStyle2Accent6;

            //To set category title
            SetCategoryTitle(table);
            //Iterates and sets the values to the table cells.
            for (int rowIndex = 0; rowIndex < table.Rows.Count; rowIndex++)
            {
                IRow row = table.Rows[rowIndex];
                if (rowIndex == 0)
                {
                    AddHeaderRow(row, dataSet.Tables[0].Rows);
                }
                else
                {
                    AddCell(row, dataSet.Tables[rowIndex + 1]);
                }
            }
            #endregion

            return(new PresentationResult(presentation, "Tables.pptx", HttpContext.ApplicationInstance.Response));
        }
Ejemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sld">当前ppt页面</param>
        /// <param name="dt">数据</param>
        /// <param name="fc">第一坐标列</param>
        /// <param name="sc">第二坐标列</param>
        /// <param name="index">图表所属表格排序(当前slide)</param>
        public static void DoubleAxexchart(ISlide sld, System.Data.DataTable dt, int index, int fc, int sc)
        {
            IChart t1    = (IChart)sld.Shapes[index];
            string range = "Sheet1!$A$1:$" + Base_ColumnsHelper.GET_INDEX(dt.Columns.Count) + "$" + (dt.Rows.Count + 1);

            //实例化图表数据表
            IChartDataWorkbook fact = t1.ChartData.ChartDataWorkbook;

            t1.Axes.SecondaryVerticalAxis.IsAutomaticMajorUnit = true;
            t1.Axes.SecondaryVerticalAxis.IsAutomaticMaxValue  = true;
            t1.Axes.SecondaryVerticalAxis.IsAutomaticMinorUnit = true;
            t1.Axes.SecondaryVerticalAxis.IsAutomaticMinValue  = true;

            t1.ChartData.ChartDataWorkbook.Clear(0);

            Workbook     workbook = Office_TableToWork.GetWorkBooxFromDataTable(dt);
            MemoryStream mem      = new MemoryStream();

            workbook.Save(mem, Aspose.Cells.SaveFormat.Xlsx);

            t1.ChartData.WriteWorkbookStream(mem);

            t1.ChartData.SetRange(range);

            IChartSeries series = t1.ChartData.Series[fc];

            series.Type = ChartType.ClusteredColumn;
            series.Labels.DefaultDataLabelFormat.ShowValue = true;
            series.Labels.DefaultDataLabelFormat.Position  = LegendDataLabelPosition.Center;
            series.Labels.DefaultDataLabelFormat.TextFormat.TextBlockFormat.TextVerticalType = TextVerticalType.Vertical270;

            ////设置第二个系列表
            IChartSeries series1 = t1.ChartData.Series[sc];

            series1.PlotOnSecondAxis = true;
            series1.Type             = ChartType.StackedLineWithMarkers;
            series1.Labels.DefaultDataLabelFormat.ShowValue = true;
            series1.Labels.DefaultDataLabelFormat.Position  = LegendDataLabelPosition.Top;
            series1.Labels.DefaultDataLabelFormat.TextFormat.TextBlockFormat.TextVerticalType = TextVerticalType.Vertical270;
        }
        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
            }
        }
Ejemplo n.º 7
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Charts();

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

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

            //Instantiate the presentation//Instantiate the presentation
            Presentation pres = new Presentation();

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

            //Adding a defautlt clustered column chart
            IChart chart = slide.Shapes.AddChart(ChartType.ClusteredColumn, 50, 50, 500, 400);

            //Accessing the chart series collection
            IChartSeriesCollection series = chart.ChartData.Series;

            //Setting the preset number format
            //Traverse through every chart series
            foreach (ChartSeries ser in series)
            {
                //Traverse through every data cell in series
                foreach (IChartDataPoint cell in ser.DataPoints)
                {
                    //Setting the number format
                    cell.Value.AsCell.PresetNumberFormat = 10; //0.00%
                }
            }

            //Saving presentation
            pres.Save(dataDir + "PresetNumberFormat.pptx", SaveFormat.Pptx);
        }
        private void btnRun_Click(object sender, EventArgs e)
        {
            //create PPT document and load PPT file from disk
            Presentation presentation = new Presentation();

            presentation.LoadFromFile(@"..\..\..\..\..\..\Data\source.pptx");

            //Load the another document and choose the first slide to be cloned.
            Presentation ppt1 = new Presentation();

            ppt1.LoadFromFile(@"..\..\..\..\..\..\Data\Presentation1.pptx");
            ISlide slide1 = ppt1.Slides[0];

            //Insert the slide to the specified index in the source presentation
            int index = 1;

            presentation.Slides.Insert(index, slide1);

            //save the document
            presentation.SaveToFile("ClonedSlide.pptx", FileFormat.Pptx2010);
            System.Diagnostics.Process.Start("ClonedSlide.pptx");
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Creates slide with title content.
        /// </summary>
        /// <param name="presentation">Represents the presentation instance.</param>
        private void CreateSlideWithTitle(IPresentation presentation)
        {
            #region Slide1
            //Sets the size and position for the shape.
            ISlide slide = presentation.Slides[0];
            IShape shape = slide.Shapes[0] as IShape;
            //Sets the properties of the shape.
            SetShapeBounds(shape, 108, 139.68, 743.04, 144);

            //Sets the text property for the shape.
            ITextBody   textFrame  = shape.TextBody;
            IParagraphs paragraphs = textFrame.Paragraphs;
            IParagraph  paragraph  = paragraphs.Add();
            ITextPart   textPart   = paragraph.AddTextPart();
            paragraphs[0].IndentLevelNumber = 0;
            textPart.Text          = "ESSENTIAL PRESENTATION";
            textPart.Font.FontName = "HelveticaNeue LT 65 Medium";
            textPart.Font.FontSize = 48;
            textPart.Font.Bold     = true;
            slide.Shapes.RemoveAt(1);
            #endregion
        }
Ejemplo n.º 10
0
        public void ChangeStudierendementSlide2(
            int aso,
            int tso,
            int bso,
            int kso,
            int index)
        {
            ISlide slide = this.PowerPoint.Slides[25];
            ITable table = slide.Tables[0];

            //IPresentationChart chart = slide.Charts[0];

            if (index == 1)
            {
                this.ChangeTableHeading3(table);
            }

            table.Columns[table.Columns.Count - index].Cells[1].TextBody.Text = EHBFunctions.FormatStringPercent(aso);
            table.Columns[table.Columns.Count - index].Cells[2].TextBody.Text = EHBFunctions.FormatStringPercent(tso);
            table.Columns[table.Columns.Count - index].Cells[3].TextBody.Text = EHBFunctions.FormatStringPercent(bso);
            table.Columns[table.Columns.Count - index].Cells[4].TextBody.Text = EHBFunctions.FormatStringPercent(kso);
        }
Ejemplo n.º 11
0
        public void ChangeInstroomSlide5(
            int aso,
            int tso,
            int bso,
            int kso,
            int buiteland,
            int index)
        {
            ISlide slide = this.PowerPoint.Slides[9];
            ITable table = slide.Tables[0];

            if (index == 1)
            {
                this.ChangeTableHeading(table);
            }

            table.Columns[table.Columns.Count - index].Cells[1].TextBody.Text = EHBFunctions.FormatStringPercent(aso);
            table.Columns[table.Columns.Count - index].Cells[2].TextBody.Text = EHBFunctions.FormatStringPercent(tso);
            table.Columns[table.Columns.Count - index].Cells[3].TextBody.Text = EHBFunctions.FormatStringPercent(bso);
            table.Columns[table.Columns.Count - index].Cells[4].TextBody.Text = EHBFunctions.FormatStringPercent(kso);
            table.Columns[table.Columns.Count - index].Cells[5].TextBody.Text = EHBFunctions.FormatStringPercent(buiteland);
        }
Ejemplo n.º 12
0
        public static void Run()
        {
            //ExStart:FillShapesGradient
            // 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// Instantiate Prseetation class that represents the PPTX
            using (Presentation pres = new Presentation())
            {
                // Get the first slide
                ISlide sld = pres.Slides[0];

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

                // Apply some gradiant formatting to ellipse shape
                shp.FillFormat.FillType = FillType.Gradient;
                shp.FillFormat.GradientFormat.GradientShape = GradientShape.Linear;

                // Set the Gradient Direction
                shp.FillFormat.GradientFormat.GradientDirection = GradientDirection.FromCorner2;

                // Add two Gradiant Stops
                shp.FillFormat.GradientFormat.GradientStops.Add((float)1.0, PresetColor.Purple);
                shp.FillFormat.GradientFormat.GradientStops.Add((float)0, PresetColor.Red);

                //Write the PPTX file to disk
                pres.Save(dataDir + "EllipseShpGrad_out.pptx", SaveFormat.Pptx);
            }
            //ExEnd:FillShapesGradient
        }
Ejemplo n.º 13
0
        public static void Run()
        {
            //ExStart:CloneToAnotherPresentationWithMaster
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Slides_Presentations_CRUD();

            // Instantiate Presentation class to load the source presentation file

            using (Presentation srcPres = new Presentation(dataDir + "CloneToAnotherPresentationWithMaster.pptx"))
            {
                // Instantiate Presentation class for destination presentation (where slide is to be cloned)
                using (Presentation destPres = new Presentation())
                {
                    // Instantiate ISlide from the collection of slides in source presentation along with
                    // Master slide
                    ISlide       SourceSlide  = srcPres.Slides[0];
                    IMasterSlide SourceMaster = SourceSlide.LayoutSlide.MasterSlide;

                    // Clone the desired master slide from the source presentation to the collection of masters in the
                    // Destination presentation
                    IMasterSlideCollection masters    = destPres.Masters;
                    IMasterSlide           DestMaster = SourceSlide.LayoutSlide.MasterSlide;

                    // Clone the desired master slide from the source presentation to the collection of masters in the
                    // Destination presentation
                    IMasterSlide iSlide = masters.AddClone(SourceMaster);

                    // Clone the desired slide from the source presentation with the desired master to the end of the
                    // Collection of slides in the destination presentation
                    ISlideCollection slds = destPres.Slides;
                    slds.AddClone(SourceSlide, iSlide, true);

                    // Clone the desired master slide from the source presentation to the collection of masters in the // Destination presentation
                    // Save the destination presentation to disk
                    destPres.Save(dataDir + "CloneToAnotherPresentationWithMaster_out.pptx", SaveFormat.Pptx);
                }
            }
            //ExEnd:CloneToAnotherPresentationWithMaster
        }
Ejemplo n.º 14
0
        public static void Run()
        {
            //ExStart:CloneShapes
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Shapes();

            // Instantiate Presentation class
            using (Presentation srcPres = new Presentation(dataDir + "Source Frame.pptx"))
            {
                IShapeCollection sourceShapes = srcPres.Slides[0].Shapes;
                ILayoutSlide     blankLayout  = srcPres.Masters[0].LayoutSlides.GetByType(SlideLayoutType.Blank);
                ISlide           destSlide    = srcPres.Slides.AddEmptySlide(blankLayout);
                IShapeCollection destShapes   = destSlide.Shapes;
                destShapes.AddClone(sourceShapes[1], 50, 150 + sourceShapes[0].Height);
                destShapes.AddClone(sourceShapes[2]);
                destShapes.InsertClone(0, sourceShapes[0], 50, 150);

                // Write the PPTX file to disk
                srcPres.Save(dataDir + "CloneShape_out.pptx", SaveFormat.Pptx);
                //ExStart:CloneShapes
            }
        }
Ejemplo n.º 15
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:SetSizeAndType
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Slides_Presentations_Layout();

            // ExStart:SettSizeAndType
            // Instantiate a Presentation object that represents a presentation file
            Presentation presentation    = new Presentation(dataDir + "AccessSlides.pptx");
            Presentation auxPresentation = new Presentation();

            ISlide slide = presentation.Slides[0];

            // Set the slide size of generated presentations to that of source
            auxPresentation.SlideSize.SetSize(presentation.SlideSize.Type, SlideSizeScaleType.EnsureFit);

            auxPresentation.Slides.InsertClone(0, slide);
            auxPresentation.Slides.RemoveAt(0);
            // Save Presentation to disk
            auxPresentation.Save(dataDir + "Set_Size&Type_out.pptx", SaveFormat.Pptx);
            //ExEnd:SetSizeAndType
        }
Ejemplo n.º 17
0
        public static string GetSlideText(string docName, int index)
        {
            string sldText = "";

            //Instantiate PresentationEx class that represents PPTX
            using (Presentation pres = new Presentation(docName))
            {
                //Access the slide
                ISlide sld = pres.Slides[index];

                //Iterate through shapes to find the placeholder
                foreach (Shape shp in sld.Shapes)
                {
                    if (shp.Placeholder != null)
                    {
                        //get the text of each placeholder
                        sldText += ((AutoShape)shp).TextFrame.Text;
                    }
                }
            }
            return(sldText);
        }
Ejemplo n.º 18
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var userid = Request.QueryString["id"];

        if (userid != null)
        {
            DataCommand command = new DataCommand("getActiveSlides");
            command.Add("userid", userid);

            DataSet      ds     = (DataSet)command.Execute(true);
            DataTable    dt     = ds.Tables[0];
            Presentation newP   = new Presentation();
            Presentation helper = new Presentation();
            var          pname  = "";

            foreach (DataRow dr in dt.Rows)
            {
                var   presentationName = dr["presentationid"].ToString() + dr["type"].ToString();
                Int32 slideIndex       = Convert.ToInt32(dr["slideindex"].ToString());
                Int32 orderNumber      = Convert.ToInt32(dr["ordernumber"].ToString());
                //if(pname !=  presentationName) {
                helper.LoadFromFile(Server.MapPath("~/Uploads/" + presentationName)); //loading ppt file
                pname = presentationName;
                //}
                ISlide orgSlide = helper.Slides[slideIndex]; // reading the slide
                newP.Slides.Insert(orderNumber, orgSlide);   // inserting in to new ppt
            }

            //newP.SaveToFile(Server.MapPath("~/Uploads/tt.ppt"), FileFormat.PPT);

            Byte[] Content = newP.GetBytes();

            Response.ContentType = "application/octet-stream";
            Response.AddHeader("content-disposition", "attachment; filename=presentation.ppt");
            Response.BufferOutput = true;
            Response.OutputStream.Write(Content, 0, Content.Length);
            Response.End(); //downloading it
        }
    }
Ejemplo n.º 19
0
        public static void Run()
        {
            // ExStart:SetAutofitOftextframe
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Text();

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

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

            // Add an AutoShape of Rectangle type
            IAutoShape ashp = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 150, 75, 350, 350);

            // Add TextFrame to the Rectangle
            ashp.AddTextFrame(" ");
            ashp.FillFormat.FillType = FillType.NoFill;

            // Accessing the text frame
            ITextFrame txtFrame = ashp.TextFrame;

            txtFrame.TextFrameFormat.AutofitType = TextAutofitType.Shape;

            // Create the Paragraph object for text frame
            IParagraph para = txtFrame.Paragraphs[0];

            // Create Portion object for paragraph
            IPortion portion = para.Portions[0];

            portion.Text = "A quick brown fox jumps over the lazy dog. A quick brown fox jumps over the lazy dog.";
            portion.PortionFormat.FillFormat.FillType             = FillType.Solid;
            portion.PortionFormat.FillFormat.SolidFillColor.Color = Color.Black;

            // ExEnd:SetAutofitOftextframe
            // Save Presentation
            presentation.Save(dataDir + "formatText_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];

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

                // Set the fill color of the rectangle shape
                shp.FillFormat.FillType             = FillType.Solid;
                shp.FillFormat.SolidFillColor.Color = Color.White;

                // Apply some formatting on the line of the rectangle
                shp.LineFormat.Style     = LineStyle.ThickThin;
                shp.LineFormat.Width     = 7;
                shp.LineFormat.DashStyle = LineDashStyle.Dash;

                // Set the color of the line of rectangle
                shp.LineFormat.FillFormat.FillType             = FillType.Solid;
                shp.LineFormat.FillFormat.SolidFillColor.Color = Color.Blue;

                //Write the PPTX file to disk
                pres.Save(dataDir + "RectShpLn_out.pptx", SaveFormat.Pptx);
            }
        }
        public static void Run()
        {
            //ExStart:EmbeddedVideoFrame
            // The path to the documents directory.
            string dataDir    = RunExamples.GetDataDir_Shapes();
            string videoDir   = RunExamples.GetDataDir_Video();
            string resultPath = Path.Combine(RunExamples.OutPath, "VideoFrame_out.pptx");

            // 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];

                // Embedd vide inside presentation
                IVideo vid = pres.Videos.AddVideo(new FileStream(videoDir + "Wildlife.mp4", FileMode.Open), LoadingStreamBehavior.ReadStreamAndRelease);

                // Add Video Frame
                IVideoFrame vf = sld.Shapes.AddVideoFrame(50, 150, 300, 350, vid);

                // Set video to Video Frame
                vf.EmbeddedVideo = vid;

                // Set Play Mode and Volume of the Video
                vf.PlayMode = VideoPlayModePreset.Auto;
                vf.Volume   = AudioVolumeMode.Loud;

                // Write the PPTX file to disk
                pres.Save(resultPath, SaveFormat.Pptx);
            }
            //ExEnd:EmbeddedVideoFrame
        }
        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:TextFormattingInsideTable
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Tables();

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

            ISlide slide = presentation.Slides[0];

            ITable someTable = presentation.Slides[0].Shapes[0] as ITable; // let's say that the first shape on the first slide is a table

            // setting table cells' font height
            PortionFormat portionFormat = new PortionFormat();

            portionFormat.FontHeight = 25;
            someTable.SetTextFormat(portionFormat);

            // setting table cells' text alignment and right margin in one call
            ParagraphFormat paragraphFormat = new ParagraphFormat();

            paragraphFormat.Alignment   = TextAlignment.Right;
            paragraphFormat.MarginRight = 20;
            someTable.SetTextFormat(paragraphFormat);

            // setting table cells' text vertical type
            TextFrameFormat textFrameFormat = new TextFrameFormat();

            textFrameFormat.TextVerticalType = TextVerticalType.Vertical;
            someTable.SetTextFormat(textFrameFormat);


            presentation.Save(path + "result.pptx", Aspose.Slides.Export.SaveFormat.Pptx);


            // ExEnd:SetTextFormattingInsideTable
        }
Ejemplo n.º 24
0
        private void btn_findhidden_Click(object sender, EventArgs e)
        {
            using (Presentation p = new Presentation(dataDir + "single.ppt"))
            {
                ISlide slide = p.Slides[0];
                string code  = string.Empty;

                //Iterating through all shapes inside the slide
                for (int i = 0; i < slide.Shapes.Count; i++)
                {
                    if (slide.Shapes[i].AsISlideComponent.GetType() == typeof(Aspose.Slides.AutoShape))
                    {
                        if (((IAutoShape)slide.Shapes[i]).TextFrame.Text == "检查类别")
                        {
                            ((IAutoShape)slide.Shapes[i]).TextFrame.Text = "修改后的检查类别";
                        }
                        if (((IAutoShape)slide.Shapes[i]).TextFrame.Text == "问题描述")
                        {
                            ((IAutoShape)slide.Shapes[i]).TextFrame.Text = "修改后的问题描述";
                        }

                        /*** 2003版本slide.Shapes[i]).Name值会丢失
                         * if (((IAutoShape)slide.Shapes[i]).Name == "code")
                         * {
                         *
                         *  code= ((IAutoShape)slide.Shapes[i]).TextFrame.Text;
                         * }
                         ****/
                        if (((IAutoShape)slide.Shapes[i]).TextFrame.Text.Contains("#code#"))
                        {
                            code = ((IAutoShape)slide.Shapes[i]).TextFrame.Text.Replace("#code#", "");
                        }
                    }
                }
                p.Save(dataDir + "findhidden.ppt", SaveFormat.Ppt);
                MessageBox.Show(code);
            }
        }
Ejemplo n.º 25
0
        public static void Run()
        {
            //ExStart:FillShapesPattern
            // 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];

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

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

                // Set the pattern style
                shp.FillFormat.PatternFormat.PatternStyle = PatternStyle.Trellis;

                // Set the pattern back and fore colors
                shp.FillFormat.PatternFormat.BackColor.Color = Color.LightGray;
                shp.FillFormat.PatternFormat.ForeColor.Color = Color.Yellow;

                //Write the PPTX file to disk
                pres.Save(dataDir + "RectShpPatt_out.pptx", SaveFormat.Pptx);
            }
            //ExEnd:FillShapesPattern
        }
Ejemplo n.º 26
0
        private void CreateFirstSlide(IPresentation presentation)
        {
            ISlide slide1 = presentation.Slides[0];
            IShape shape1 = slide1.Shapes[0] as IShape;

            shape1.Left   = 1.5 * 72;
            shape1.Top    = 1.94 * 72;
            shape1.Width  = 10.32 * 72;
            shape1.Height = 2 * 72;

            ITextBody   textFrame1  = shape1.TextBody;
            IParagraphs paragraphs1 = textFrame1.Paragraphs;
            IParagraph  paragraph1  = paragraphs1.Add();
            ITextPart   textPart1   = paragraph1.AddTextPart();

            paragraphs1[0].IndentLevelNumber = 0;
            textPart1.Text          = "Essential Presentation";
            textPart1.Font.FontName = "HelveticaNeue LT 65 Medium";
            textPart1.Font.CapsType = TextCapsType.All;
            textPart1.Font.FontSize = 48;
            textPart1.Font.Bold     = true;
            slide1.Shapes.RemoveAt(1);
        }
Ejemplo n.º 27
0
        public static void Run()
        {
            //ExStart:ChangeShapeOrder
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Shapes();

            Presentation presentation1 = new Presentation(dataDir + "HelloWorld.pptx");
            ISlide       slide         = presentation1.Slides[0];
            IAutoShape   shp3          = slide.Shapes.AddAutoShape(ShapeType.Rectangle, 200, 365, 400, 150);

            shp3.FillFormat.FillType = FillType.NoFill;
            shp3.AddTextFrame(" ");

            ITextFrame txtFrame = shp3.TextFrame;
            IParagraph para     = txtFrame.Paragraphs[0];
            IPortion   portion  = para.Portions[0];

            portion.Text = "Watermark Text Watermark Text Watermark Text";
            shp3         = slide.Shapes.AddAutoShape(ShapeType.Triangle, 200, 365, 400, 150);
            slide.Shapes.Reorder(2, shp3);
            presentation1.Save(dataDir + "Reshape_out.pptx", SaveFormat.Pptx);
            //ExEnd:ChangeShapeOrder
        }
Ejemplo n.º 28
0
        public static void Run()
        {
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Shapes();

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

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

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

            // Set the fill type to Solid
            shape.FillFormat.FillType = FillType.Solid;

            // Set the color of the rectangle
            shape.FillFormat.SolidFillColor.Color = Color.Yellow;

            //Write the PPTX file to disk
            presentation.Save(dataDir + "RectShpSolid_out.pptx", SaveFormat.Pptx);
        }
Ejemplo n.º 29
0
        public async Task <ISlide> GetNextSlideAsync(ISlide slide)
        {
            if (slide == null)
            {
                throw new ArgumentNullException(nameof(slide));
            }

            var next = await context.Slides.Where(x => x.SectionId == slide.SectionId && x.Order > slide.Order).OrderBy(x => x.Order).FirstOrDefaultAsync();

            if (next == null)
            {
                var section = await context.Sections.Where(x => x.SectionId == slide.SectionId).SingleAsync();

                var nextSection = await context.Sections.Where(x => x.Order > section.Order).OrderBy(x => x.Order).FirstOrDefaultAsync();

                if (nextSection == null)
                {
                    return(null);
                }
                next = await context.Slides.Where(x => x.SectionId == nextSection.SectionId).OrderBy(x => x.Order).FirstOrDefaultAsync();
            }
            return(next);
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Get extracted OLE document
        /// </summary>
        /// <returns>Return the ole document as stream</returns>
        public MemoryStream ExtractOleObject()
        {
            //Opens the presentation document as stream
            FileStream    fileStreamInput = new FileStream(ResolveApplicationPath("embedded-ole-object.pptx"), FileMode.Open, FileAccess.Read);
            IPresentation pptxDoc         = Syncfusion.Presentation.Presentation.Open(fileStreamInput);
            //New Instance of PowerPoint is Created.[Equivalent to launching MS PowerPoint with no slides].

            //Gets the first slide of the Presentation
            ISlide slide = pptxDoc.Slides[0];
            //Gets the Ole Object of the slide
            IOleObject oleObject = slide.Shapes[2] as IOleObject;

            //Gets the file data of embedded Ole Object.
            byte[] array = oleObject.ObjectData;
            //Gets the file Name of OLE Object
            string outputFile = oleObject.FileName;

            //Save the document as a stream and retrun the stream
            using (MemoryStream stream = new MemoryStream(array))
            {
                return(stream);
            }
        }
        public static void Run()
        {
            //ExStart:SetSlideSizeScale
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Slides_Presentations_Layout();

            // ExStart:SettSizeAndType
            // Instantiate a Presentation object that represents a presentation file
            Presentation presentation    = new Presentation(dataDir + "AccessSlides.pptx");
            Presentation auxPresentation = new Presentation();

            ISlide slide = presentation.Slides[0];

            // Set the slide size of generated presentations to that of source
            presentation.SlideSize.SetSize(540, 720, SlideSizeScaleType.EnsureFit);             // Method SetSize is used for set slide size with scale content to ensure fit
            presentation.SlideSize.SetSize(SlideSizeType.A4Paper, SlideSizeScaleType.Maximize); // Method SetSize is used for set slide size with maximize size of content



            // Save Presentation to disk
            auxPresentation.Save(dataDir + "Set_Size&Type_out.pptx", SaveFormat.Pptx);
            //ExEnd:SetSlideSizeScale
        }
Ejemplo n.º 32
0
        public static void PPTFindAndReplace(Presentation pres, string findString, string replaceString, int index = 0)
        {
            ISlide slide = pres.Slides[index];

            ITextFrame[] cb = SlideUtil.GetAllTextFrames(pres, true);
            for (int i = 1; i < cb.Length; i++)
            {
                foreach (Paragraph para in cb[i].Paragraphs)
                {
                    foreach (Portion port in para.Portions)
                    {
                        if (port.Text.Contains(findString))
                        {
                            string str          = port.Text;
                            int    idx          = str.IndexOf(findString);
                            string strStartText = str.Substring(0, idx);
                            string strEndText   = str.Substring(idx + findString.Length, str.Length - 1 - (idx + findString.Length - 1));
                            port.Text = strStartText + replaceString + strEndText;
                        }
                    }
                }
            }
        }
 void IHtmlFormattingController.WriteSlideStart(IHtmlGenerator generator, ISlide slide)
 {
     generator.AddHtml(string.Format(SlideHeader, generator.SlideIndex + 1));
 }
 void IHtmlFormattingController.WriteSlideEnd(IHtmlGenerator generator, ISlide slide)
 {
     generator.AddHtml(SlideFooter);
 }