Example #1
0
    static void Main()
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        var presentation = new PresentationDocument();

        // Create new master slide.
        var master = presentation.MasterSlides.AddNew();

        master.Content.AddPlaceholder(PlaceholderType.Date);
        master.Content.AddPlaceholder(PlaceholderType.SlideNumber);

        // Set "DateTime" and "SlideNumber" placeholders visible on slides.
        master.HeaderFooter.IsDateTimeEnabled    = true;
        master.HeaderFooter.IsSlideNumberEnabled = true;

        // Create new slides; will inherit "DateTime" and "SlideNumber" placeholders from master slide.
        var slide = presentation.Slides.AddNew(SlideLayoutType.VerticalTitleAndText);

        slide = presentation.Slides.AddNew(SlideLayoutType.TwoObjects);
        slide = presentation.Slides.AddNew(SlideLayoutType.TwoObjectsAndText);

        presentation.Save("Header and Footer.pptx");
    }
    static void Main()
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        var presentation = new PresentationDocument();

        // Get slide size.
        var size = presentation.SlideSize;

        // Set slide size.
        size.SizedFor         = SlideSizeType.OnscreenShow16X10;
        size.Orientation      = Orientation.Landscape;
        size.NumberSlidesFrom = 1;

        // Create new master slide.
        var master = presentation.MasterSlides.AddNew();

        // Create new layout slide for existing master slide.
        var layout = master.LayoutSlides.AddNew(SlideLayoutType.TitleAndObject);

        // Create new slide from existing template layout slide.
        var slide = presentation.Slides.AddNew(layout);

        // If master slide collection is empty, this method will add a new master slide.
        // If layout slide collection of the last master slide doesn't contain a layout slide with the specified type,
        // then a new layout slide with the specified type will be added.
        slide = presentation.Slides.AddNew(SlideLayoutType.TwoTextAndTwoObjects);

        presentation.Save("Slides.pptx");
    }
    static void Main()
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        var presentation = new PresentationDocument();

        // Sets the base directory path where component looks for fonts.
        FontSettings.FontsBaseDirectory = ".";

        var slide = presentation.Slides.AddNew(SlideLayoutType.Custom);

        var textBox = slide.Content.AddTextBox(
            ShapeGeometryType.Rectangle, 2, 2, 8, 8, LengthUnit.Centimeter);

        textBox.Shape.Format.Outline.Fill.SetSolid(Color.FromName(ColorName.DarkGray));

        var run = textBox.AddParagraph().AddRun(
            "Shows how to use private fonts with GemBox.Presentation component.");

        run.Format.Font = "Almonte Snow";
        run.Format.Size = Length.From(16, LengthUnit.Point);
        run.Format.Fill.SetSolid(Color.FromName(ColorName.Black));

        presentation.Save("Private Fonts.pdf");
    }
Example #4
0
        public IActionResult Download(string format)
        {
            // Create new presentation.
            var presentation = new PresentationDocument();

            // Add slide.
            var slide = presentation.Slides.AddNew(SlideLayoutType.Custom);

            // Add textbox.
            var textBox = slide.Content.AddTextBox(ShapeGeometryType.Rectangle, 2, 2, 5, 4, LengthUnit.Centimeter);

            // Add paragraph.
            var paragraph = textBox.AddParagraph();

            // Add text.
            paragraph.AddRun("Hello World!");

            using (var stream = new MemoryStream())
            {
                // Save presentation to stream in specified format.
                SaveOptions options = GetSaveOptions(format);
                presentation.Save(stream, options);

                // Download presentation to client's browser.
                return(File(stream.ToArray(), options.ContentType, "Hello World." + format.ToLower()));
            }
        }
    public static async Task <IActionResult> Run(
        [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = null)] HttpRequest req,
        ILogger log)
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        var presentation = new PresentationDocument();

        var slide = presentation.Slides.AddNew(SlideLayoutType.Custom);

        var textBox = slide.Content.AddTextBox(ShapeGeometryType.Rectangle, 2, 2, 5, 4, LengthUnit.Centimeter);

        var paragraph = textBox.AddParagraph();

        paragraph.AddRun("Hello World!");

        var fileName = "Output.pptx";
        var options  = SaveOptions.Pptx;

        using (var stream = new MemoryStream())
        {
            presentation.Save(stream, options);
            return(new FileContentResult(stream.ToArray(), options.ContentType)
            {
                FileDownloadName = fileName
            });
        }
    }
Example #6
0
        private void button2_Click(object sender, EventArgs e)
        {
            // Set license key to use GemBox.Presentation in Free mode.
            ComponentInfo.SetLicense("FREE-LIMITED-KEY");
            var presentation = new PresentationDocument();
            var slide        = presentation.Slides.AddNew(SlideLayoutType.Custom);
            var textBox      = slide.Content.AddTextBox(0, 0, 5, 5, LengthUnit.Centimeter);

            textBox.AddParagraph().AddRun("Hello World!");



            // Save to PPTX and PDF files.
            presentation.Save("Presentation.pptx");
            //open it
            var app  = new PowerPoint.Application();
            var pres = app.Presentations;
            var file = pres.Open(@"C:\Users\real1\Desktop\Crypto_project\Audit\Audit\bin\Debug\Presentation.pptx", MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoFalse);

            PowerPoint.SlideShowSettings slideSetting = file.SlideShowSettings;
            slideSetting.Run();

            PowerPoint.SlideShowWindows slideShowWindows = app.SlideShowWindows;
            while (true)
            {
                if (slideShowWindows.Count <= 0)
                {
                    break;
                }
                System.Threading.Thread.Sleep(100);
            }
        }
    static void Main()
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        var presentation = new PresentationDocument();

        // Create new slide; will create "custom" layout slide and default master slide.
        var slide = presentation.Slides.AddNew(SlideLayoutType.Custom);

        slide.Content.AddShape(ShapeGeometryType.RectangularCallout, 30, 30, 130, 100, LengthUnit.Point).Format.Fill.SetSolid(Color.FromName(ColorName.AliceBlue));
        slide.Content.AddShape(ShapeGeometryType.RoundedRectangularCallout, 170, 30, 130, 100, LengthUnit.Point).Format.Fill.SetSolid(Color.FromName(ColorName.BlueViolet));
        slide.Content.AddShape(ShapeGeometryType.OvalCallout, 310, 30, 130, 100, LengthUnit.Point).Format.Fill.SetSolid(Color.FromName(ColorName.CadetBlue));
        slide.Content.AddShape(ShapeGeometryType.CloudCallout, 450, 30, 130, 100, LengthUnit.Point).Format.Fill.SetSolid(Color.FromName(ColorName.CornflowerBlue));

        slide.Content.AddShape(ShapeGeometryType.ActionButtonEnd, 30, 150, 130, 100, LengthUnit.Point).Format.Fill.SetSolid(Color.FromName(ColorName.DarkSeaGreen));
        slide.Content.AddShape(ShapeGeometryType.ActionButtonForwardOrNext, 170, 150, 130, 100, LengthUnit.Point).Format.Fill.SetSolid(Color.FromName(ColorName.ForestGreen));
        slide.Content.AddShape(ShapeGeometryType.ActionButtonHelp, 310, 150, 130, 100, LengthUnit.Point).Format.Fill.SetSolid(Color.FromName(ColorName.GreenYellow));
        slide.Content.AddShape(ShapeGeometryType.ActionButtonHome, 450, 150, 130, 100, LengthUnit.Point).Format.Fill.SetSolid(Color.FromName(ColorName.LightSeaGreen));

        slide.Content.AddShape(ShapeGeometryType.UpArrow, 30, 270, 130, 100, LengthUnit.Point).Format.Fill.SetSolid(Color.FromName(ColorName.DarkRed));
        slide.Content.AddShape(ShapeGeometryType.UpArrowCallout, 170, 270, 130, 100, LengthUnit.Point).Format.Fill.SetSolid(Color.FromName(ColorName.IndianRed));
        slide.Content.AddShape(ShapeGeometryType.UpDownArrow, 310, 270, 130, 100, LengthUnit.Point).Format.Fill.SetSolid(Color.FromName(ColorName.OrangeRed));
        slide.Content.AddShape(ShapeGeometryType.UpDownArrowCallout, 450, 270, 130, 100, LengthUnit.Point).Format.Fill.SetSolid(Color.FromName(ColorName.MediumVioletRed));

        presentation.Save("Shapes.pptx");
    }
Example #8
0
    static void Main()
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        var presentation = new PresentationDocument();

        // Create new presentation slide.
        var slide = presentation.Slides.AddNew(SlideLayoutType.Custom);

        // Create new table.
        var table = slide.Content.AddTable(5, 5, 20, 5, LengthUnit.Centimeter);

        // Format table with no-style grid.
        table.Format.Style = presentation.TableStyles.GetOrAdd(
            TableStyleName.NoStyleTableGrid);

        table.Format.Fill.SetSolid(Color.FromName(ColorName.Orange));

        table.Columns.AddNew(Length.From(7, LengthUnit.Centimeter));
        table.Columns.AddNew(Length.From(10, LengthUnit.Centimeter));
        table.Columns.AddNew(Length.From(5, LengthUnit.Centimeter));

        var row = table.Rows.AddNew(Length.From(5, LengthUnit.Centimeter));

        var cell = row.Cells.AddNew();

        cell.Format.Fill.SetSolid(Color.FromName(ColorName.Red));

        cell.Text.Format.VerticalAlignment = VerticalAlignment.Top;

        cell.Text.AddParagraph().AddRun("Cell 1-1");

        cell = row.Cells.AddNew();

        var border = cell.Format.DiagonalDownBorderLine;

        border.Fill.SetSolid(Color.FromName(ColorName.White));
        border.Width = Length.From(5, LengthUnit.Millimeter);

        border = cell.Format.DiagonalUpBorderLine;

        border.Fill.SetSolid(Color.FromName(ColorName.White));
        border.Width = Length.From(5, LengthUnit.Millimeter);

        cell.Text.Format.VerticalAlignment = VerticalAlignment.Middle;

        cell.Text.AddParagraph().AddRun("Cell 1-2");

        cell = row.Cells.AddNew();

        cell.Format.Fill.SetSolid(Color.FromName(ColorName.DarkBlue));

        cell.Text.Format.VerticalAlignment = VerticalAlignment.Bottom;

        cell.Text.AddParagraph().AddRun("Cell 1-3");

        presentation.Save("Table Formatting.pptx");
    }
Example #9
0
    static void Main()
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        var presentation = new PresentationDocument();

        // Create first slide used in custom slideshows.
        var slide1 = presentation.Slides.AddNew(SlideLayoutType.Custom);

        // Create a text box.
        var textBox = slide1.Content.AddTextBox(ShapeGeometryType.RoundedRectangle, 2, 2, 12, 4, LengthUnit.Centimeter);

        // Set shape fill and outline format.
        textBox.Shape.Format.Fill.SetSolid(Color.FromName(ColorName.BlueViolet));
        textBox.Shape.Format.Outline.Fill.SetSolid(Color.FromName(ColorName.Violet));

        // Create a paragraph with single run element.
        TextRun run = textBox.AddParagraph().AddRun("Shows how to create and customize slide shows using GemBox.Presentation API.");

        run.Format.Fill.SetSolid(Color.FromName(ColorName.White));
        run.Format.Bold = true;

        // Create other two slides used in custom slideshows.
        var slide2 = presentation.Slides.AddNew(SlideLayoutType.Custom);
        var slide3 = presentation.Slides.AddNew(SlideLayoutType.Custom);

        // Get presentation slide show settings.
        var settings = presentation.SlideShow;

        // Create first custom slideshow.
        var slideShow1 = settings.CustomShows.AddNew("CustomShow1");

        slideShow1.Slides.Add(slide1);
        slideShow1.Slides.Add(slide2);
        slideShow1.Slides.Add(slide3);

        // Create first custom slideshow.
        var slideShow2 = settings.CustomShows.AddNew("CustomShow2");

        slideShow2.Slides.Add(slide3);
        slideShow2.Slides.Add(slide2);
        slideShow2.Slides.Add(slide1);

        // Show the slides from the first custom show.
        settings.ShowCustomShowSlides("CustomShow1");

        // Slides should be manually advanced when presenting.
        settings.AdvanceMode = SlideShowAdvanceMode.Manually;

        // Slide show should loop at the end.
        settings.LoopContinuously = true;

        // Slides should be browsed at a kiosk (full screen).
        settings.ShowType = SlideShowType.Kiosk;

        presentation.Save("Slide Show.pptx");
    }
    static void Main()
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        var presentation = new PresentationDocument();

        // Create new presentation slide.
        var slide = presentation.Slides.AddNew(SlideLayoutType.Custom);

        // Create and add audio content.
        AudioContent audio = null;

        using (var stream = File.OpenRead("Applause.wav"))
            audio = slide.Content.AddAudio(AudioContentType.Wav, stream, 2, 2, LengthUnit.Centimeter);

        // Set the ending fade durations for the media.
        audio.Fade.End = TimeOffset.From(300, TimeOffsetUnit.Millisecond);

        // Get the picture associated with this media.
        var picture = audio.Picture;

        // Set drawing properties.
        picture.Action.Click.Set(ActionType.PlayMedia);
        picture.Layout.Width  = Length.From(7, LengthUnit.Centimeter);
        picture.Layout.Height = Length.From(7, LengthUnit.Centimeter);
        picture.Name          = "Applause.wav";

        // Create and add video content.
        VideoContent video = null;

        using (var stream = File.OpenRead("Wildlife.wmv"))
            video = slide.Content.AddVideo("video/x-ms-wmv", stream, 10, 2, 10, 5.6, LengthUnit.Centimeter);

        // Set drawing properties.
        video.Picture.Action.Click.Set(ActionType.PlayMedia);
        video.Picture.Name = "Wildlife.wmv";

        // Set the amount of time to be trimmed from the start and end of the media.
        video.Trim.Start = TimeOffset.From(600, TimeOffsetUnit.Millisecond);
        video.Trim.End   = TimeOffset.From(800, TimeOffsetUnit.Millisecond);

        // Set the starting and ending fade durations for the media.
        video.Fade.Start = TimeOffset.From(100, TimeOffsetUnit.Millisecond);
        video.Fade.End   = TimeOffset.From(200, TimeOffsetUnit.Millisecond);

        // Add video bookmarks.
        video.Bookmarks.Add(TimeOffset.From(1500, TimeOffsetUnit.Millisecond));
        video.Bookmarks.Add(TimeOffset.From(3000, TimeOffsetUnit.Millisecond));

        presentation.Save("Audio and Video.pptx");
    }
    static void Main()
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        var presentation = new PresentationDocument();

        // Create new slide.
        var slide = presentation.Slides.AddNew(SlideLayoutType.Custom);

        // Create new "rounded rectangle" shape.
        var shape = slide.Content.AddShape(
            ShapeGeometryType.RoundedRectangle, 2, 2, 5, 4, LengthUnit.Centimeter);

        // Get shape format.
        var format = shape.Format;

        // Get shape fill format.
        var fillFormat = format.Fill;

        // Set shape fill format as solid fill.
        fillFormat.SetSolid(Color.FromName(ColorName.DarkBlue));

        // Create new "rectangle" shape.
        shape = slide.Content.AddShape(
            ShapeGeometryType.Rectangle, 8, 2, 5, 4, LengthUnit.Centimeter);

        // Set shape fill format as solid fill.
        shape.Format.Fill.SetSolid(Color.FromName(ColorName.Yellow));

        // Set shape outline format as solid fill.
        shape.Format.Outline.Fill.SetSolid(Color.FromName(ColorName.Green));

        // Create new "rounded rectangle" shape.
        shape = slide.Content.AddShape(
            ShapeGeometryType.RoundedRectangle, 14, 2, 5, 4, LengthUnit.Centimeter);

        // Set shape fill format as no fill.
        shape.Format.Fill.SetNone();

        // Get shape outline format.
        var lineFormat = shape.Format.Outline;

        // Set shape outline format as single solid red line.
        lineFormat.Fill.SetSolid(Color.FromName(ColorName.Red));
        lineFormat.DashType     = LineDashType.Solid;
        lineFormat.Width        = Length.From(0.8, LengthUnit.Centimeter);
        lineFormat.CompoundType = LineCompoundType.Single;

        presentation.Save("Shape Formatting.pptx");
    }
    static void Main()
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        var presentation = new PresentationDocument();

        // Add a blank slide to the presentation.
        var slide = presentation.Slides.AddNew(SlideLayoutType.Blank);

        // Add a text box with some content to the slide.
        var text = slide.Content.AddTextBox(3, 2, 22, 2, LengthUnit.Centimeter);

        text.AddParagraph().AddRun("This is my presentation with notes");

        // Add notes to the slide.
        var notes = slide.AddNotes();

        // Using LINQ, find shape that contains notes text.
        var notesText = notes.Content.Drawings.OfType <Shape>().
                        Single(sp => sp.Placeholder.PlaceholderType == PlaceholderType.Text).Text;

        // Start adding notes text and formatting.
        notesText.AddParagraph().AddRun("These are my notes:");

        var noteParagraph = notesText.AddParagraph();

        // Paragraph will be numbered.
        noteParagraph.Format.List.NumberType = ListNumberType.DecimalPeriod;
        // Move paragraph content a little bit from its number.
        noteParagraph.Format.IndentationSpecial =
            Length.From(-0.64, LengthUnit.Centimeter);
        noteParagraph.AddRun("My first note");

        noteParagraph = notesText.AddParagraph();
        noteParagraph.Format.List.NumberType    = ListNumberType.DecimalPeriod;
        noteParagraph.Format.IndentationSpecial =
            Length.From(-0.64, LengthUnit.Centimeter);
        noteParagraph.AddRun("My second note");

        noteParagraph = notesText.AddParagraph();
        noteParagraph.Format.List.NumberType    = ListNumberType.DecimalPeriod;
        noteParagraph.Format.IndentationSpecial =
            Length.From(-0.64, LengthUnit.Centimeter);
        noteParagraph.AddRun("My third note");

        presentation.Save("Notes.pptx");
    }
    static void Main()
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        var presentation = new PresentationDocument();

        // Create new slide.
        var slide = presentation.Slides.AddNew(SlideLayoutType.Custom);

        // Create a text box.
        var textBox = slide.Content.AddTextBox(ShapeGeometryType.RoundedRectangle, 2, 2, 12, 4, LengthUnit.Centimeter);

        // Set shape fill and outline format.
        textBox.Shape.Format.Fill.SetSolid(Color.FromName(ColorName.OrangeRed));
        textBox.Shape.Format.Outline.Fill.SetSolid(Color.FromName(ColorName.Red));

        // Create a paragraph with single run element.
        var run = textBox.AddParagraph().AddRun("Shows how to create and customize slide transitions using GemBox.Presentation API.");

        run.Format.Fill.SetSolid(Color.FromName(ColorName.White));
        run.Format.Bold = true;

        // Get slide transition information.
        var transition = slide.Transition;

        // Set the transition type.
        transition.TransitionType = TransitionType.Fade;

        // Set the transition effect.
        transition.Effect = TransitionEffect.Smoothly;

        // Slide should advance automatically after 1 second.
        transition.AdvanceOnTime    = true;
        transition.AdvanceAfterTime = 1000;

        // Slide should advance on mouse click.
        transition.AdvanceOnClick = true;

        // Set the transition speed.
        transition.Speed = TransitionSpeed.Slow;

        // Specify the sound to be played when the transition is activated.
        using (var stream = File.OpenRead("Applause.wav"))
            transition.PlaySound(stream);

        presentation.Save("Slide Transitions.pptx");
    }
Example #14
0
    static void Main()
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        var presentation = new PresentationDocument();

        var slide = presentation.Slides.AddNew(SlideLayoutType.Custom);

        var textBox = slide.Content.AddTextBox(ShapeGeometryType.Rectangle, 2, 2, 5, 4, LengthUnit.Centimeter);

        var paragraph = textBox.AddParagraph();

        paragraph.AddRun("Hello World!");

        presentation.Save("Hello World.pptx");
    }
    static void Main()
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        var presentation = new PresentationDocument();

        // Create new presentation slide.
        var slide = presentation.Slides.AddNew(SlideLayoutType.Custom);

        // Create new table.
        var table = slide.Content.AddTable(5, 5, 20, 12, LengthUnit.Centimeter);

        // Format table with no-style grid.
        table.Format.Style = presentation.TableStyles.GetOrAdd(
            TableStyleName.NoStyleTableGrid);

        int columnCount = 4;
        int rowCount    = 10;

        for (int i = 0; i < columnCount; i++)
        {
            // Create new table column.
            table.Columns.AddNew(Length.From(5, LengthUnit.Centimeter));
        }

        for (int i = 0; i < rowCount; i++)
        {
            // Create new table row.
            var row = table.Rows.AddNew(
                Length.From(1.2, LengthUnit.Centimeter));

            for (int j = 0; j < columnCount; j++)
            {
                // Create new table cell.
                var cell = row.Cells.AddNew();

                // Set table cell text.
                cell.Text.AddParagraph().AddRun(
                    string.Format(null, "Cell {0}-{1}", i + 1, j + 1));
            }
        }

        presentation.Save("Simple Table.pptx");
    }
    static void Main()
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        var presentation = new PresentationDocument();

        var slide = presentation.Slides.AddNew(SlideLayoutType.Custom);

        slide.Content.AddTextBox(ShapeGeometryType.Rectangle, 2, 2, 20, 2, LengthUnit.Centimeter)
        .AddParagraph()
        .AddRun("This presentation has been opened in read-only mode, no changes can be made to a slide.");

        // ModifyProtection class is supported only for PPTX file format.
        presentation.ModifyProtection.SetPassword("1234");

        presentation.Save("PPTX Modify Protection.pptx");
    }
    static void Main()
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        var presentation = new PresentationDocument();

        var slide = presentation.Slides.AddNew(SlideLayoutType.Custom);

        var shape = slide.Content.AddShape(ShapeGeometryType.RoundedRectangle, 2, 2, 8, 4, LengthUnit.Centimeter);

        shape.Format.Fill.SetSolid(Color.FromName(ColorName.DarkBlue));

        var run = shape.Text.AddParagraph().AddRun("This sample shows how to write or save a new PowerPoint file with GemBox.Presentation.");

        run.Format.Fill.SetSolid(Color.FromName(ColorName.White));

        presentation.Save("Writing.pptx");
    }
        private void Select_Click(object sender, RoutedEventArgs e)
        {
            //in one spot it says minimum of 3 images on slide, but final point in keeping from passing says UP TO 3 images ¯\_(ツ)_/¯
            if (Selection.Where(x => x.Value).Count() != 3)
            {
                return;
            }

            var presentation = new PresentationDocument();
            var slide        = presentation.Slides.AddNew(SlideLayoutType.Custom);
            var textBox      = slide.Content.AddTextBox(ShapeGeometryType.Rectangle, 10, 2, 5, 4, LengthUnit.Centimeter);

            var title = textBox.AddParagraph();

            title.AddRun(Title.Text);


            var bodyTextBox = slide.Content.AddTextBox(ShapeGeometryType.Rectangle, 20, 2, 5, 4, LengthUnit.Centimeter);

            var body = bodyTextBox.AddParagraph();

            var bodyText = new System.Windows.Documents.TextRange(SearchText.Document.ContentStart, SearchText.Document.ContentEnd).Text.Replace("\r", " ");

            bodyText = bodyText.Replace("\n", " ");

            body.AddRun(bodyText);

            double width = 0.0;

            foreach (var image in Selection)
            {
                if (image.Value)
                {
                    slide.Content.AddPicture(image.Key.Source.ToString(), width, 250, image.Key.Width, image.Key.Height);
                    width += image.Key.Width;
                }
            }

            presentation.Save($"Results_{Guid.NewGuid()}.pptx");
            Image_Panel.Children.Clear();
            Images.Clear();
            Selection.Clear();
        }
Example #19
0
    static void Main()
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        var presentation = new PresentationDocument();

        // Create new master slide.
        var master = presentation.MasterSlides.AddNew();

        // Create new empty layout slide for existing master slide.
        var layout = master.LayoutSlides.AddNew(SlideLayoutType.Custom);

        // Create title and subtitle placeholders on layout slide.
        layout.Content.AddPlaceholder(PlaceholderType.Title);
        layout.Content.AddPlaceholder(PlaceholderType.Subtitle);

        // Create new slide; will inherit all placeholders (title and subtitle) from template layout slide.
        var slide = presentation.Slides.AddNew(layout);

        // Retrieve "Title" placeholder.
        var shape = slide.Content.Drawings.OfType <Shape>().Where(item => item.Placeholder?.PlaceholderType == PlaceholderType.Title).First();

        // Set shape fill and outline format.
        shape.Format.Outline.Fill.SetSolid(Color.FromName(ColorName.DarkGray));
        shape.Format.Fill.SetSolid(Color.FromName(ColorName.LightGray));

        // Set shape text.
        shape.Text.AddParagraph().AddRun("Placeholders, GemBox.Presentation");

        // Retrieve "Subtitle" placeholder.
        shape = slide.Content.Drawings.OfType <Shape>().Where(item => item.Placeholder?.PlaceholderType == PlaceholderType.Subtitle).First();

        // Set shape outline format.
        shape.Format.Outline.Fill.SetSolid(Color.FromName(ColorName.DarkGray));

        // Set shape text.
        shape.Text.AddParagraph().AddRun("Shows how to use placeholders with GemBox.Presentation component.");

        presentation.Save("Placeholders.pptx");
    }
    static void Main()
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        var presentation = new PresentationDocument();

        // Create new slide.
        var slide = presentation.Slides.AddNew(SlideLayoutType.Custom);

        // Create new text box.
        var textBox = slide.Content.AddTextBox(
            ShapeGeometryType.RoundedRectangle, 2, 2, 10, 4, LengthUnit.Centimeter);

        // Create new paragraph.
        var paragraph = textBox.AddParagraph();

        // Set paragraph text.
        paragraph.AddRun("This paragraph has the following properties: alignment is justify, after spacing is 100% of the text size, before spacing is 250% of the text size, line spacing is 200% of the text size.");

        // Set selected paragraph format.
        var format = paragraph.Format;

        format.Alignment     = HorizontalAlignment.Justify;
        format.SpacingAfter  = TextSpacing.Single;
        format.SpacingBefore = TextSpacing.Multiple(2.5);
        format.SpacingLine   = TextSpacing.Double;

        // Create new paragraph.
        paragraph = textBox.AddParagraph();

        // Set paragraph text.
        paragraph.AddRun("This paragraph has the following properties: alignment is left, indentation before text is 15 points and first line indentation is 25 points.");

        // Set selected paragraph format.
        paragraph.Format.Alignment             = HorizontalAlignment.Left;
        paragraph.Format.IndentationBeforeText = Length.From(15, LengthUnit.Point);
        paragraph.Format.IndentationSpecial    = Length.From(25, LengthUnit.Point);

        presentation.Save("Paragraph Formatting.pptx");
    }
    static void Main()
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        var presentation = new PresentationDocument();

        // Create new slide.
        var slide = presentation.Slides.AddNew(SlideLayoutType.Custom);

        // Create new text box.
        var textBox = slide.Content.AddTextBox(
            ShapeGeometryType.RoundedRectangle, 2, 2, 10, 10, LengthUnit.Centimeter);

        // Set shape format.
        textBox.Shape.Format.Fill.SetSolid(Color.FromName(ColorName.LightGray));
        textBox.Shape.Format.Outline.Fill.SetSolid(Color.FromName(ColorName.DarkGray));
        textBox.Shape.Format.Outline.Width = Length.From(1, LengthUnit.Point);

        // Set text box text.
        textBox.AddParagraph().AddRun("Shows some of the text box formatting options available in GemBox.Presentation component.");

        // Get text box format.
        var format = textBox.Format;

        // Set vertical alignment of the text.
        format.VerticalAlignment = VerticalAlignment.Middle;

        // Set left and top margin.
        format.InternalMarginLeft = Length.From(1, LengthUnit.Centimeter);
        format.InternalMarginTop  = Length.From(1, LengthUnit.Centimeter);

        // Set text direction.
        format.TextDirection = TextDirection.Rotate270;

        // Wrap text in shape.
        format.WrapText = true;

        presentation.Save("Text Box Formatting.pptx");
    }
Example #22
0
    static void Example1()
    {
        var presentation = new PresentationDocument();

        // Add new PowerPoint presentation slide.
        var slide = presentation.Slides.AddNew(SlideLayoutType.Custom);

        // Add simple PowerPoint presentation title.
        var textBox = slide.Content.AddTextBox(ShapeGeometryType.Rectangle,
                                               116.8, 20, 105, 10, GemBox.Presentation.LengthUnit.Millimeter);

        textBox.AddParagraph().AddRun("New presentation with chart element.");

        // Create PowerPoint chart and add it to slide.
        var chart = slide.Content.AddChart(GemBox.Presentation.ChartType.Bar,
                                           49.3, 40, 240, 120, GemBox.Presentation.LengthUnit.Millimeter);

        // Get underlying Excel chart.
        ExcelChart     excelChart = (ExcelChart)chart.ExcelChart;
        ExcelWorksheet worksheet  = excelChart.Worksheet;

        // Add data for Excel chart.
        worksheet.Cells["A1"].Value = "Name";
        worksheet.Cells["A2"].Value = "John Doe";
        worksheet.Cells["A3"].Value = "Fred Nurk";
        worksheet.Cells["A4"].Value = "Hans Meier";
        worksheet.Cells["A5"].Value = "Ivan Horvat";

        worksheet.Cells["B1"].Value = "Salary";
        worksheet.Cells["B2"].Value = 3600;
        worksheet.Cells["B3"].Value = 2580;
        worksheet.Cells["B4"].Value = 3200;
        worksheet.Cells["B5"].Value = 4100;

        // Select data.
        excelChart.SelectData(worksheet.Cells.GetSubrange("A1:B5"), true);

        presentation.Save("Created Chart.pdf");
    }
Example #23
0
    static void Main()
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        var presentation = new PresentationDocument();

        // Create new presentation slide.
        var slide = presentation.Slides.AddNew(SlideLayoutType.Custom);

        // Adds a new comment with a new author in the top-left corner of the slide.
        var comment = slide.Comments.Add("GBP", "GemBox.Presentation", "Shows how to use comments with GemBox.Presentation component.");

        // Change comment position.
        comment.Left = Length.From(50, LengthUnit.Centimeter);
        comment.Top  = Length.From(10, LengthUnit.Centimeter);

        // Adds a new comment with the same author as the previously added comment.
        slide.Comments.Add("Another comment from GemBox.Presentation.");

        presentation.Save("Comments.pptx");
    }
Example #24
0
    static void Main()
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        var presentation = new PresentationDocument();

        // Create new presentation slide.
        var slide = presentation.Slides.AddNew(SlideLayoutType.Custom);

        // Create first picture from resource data.
        Picture picture = null;

        using (var stream = File.OpenRead("Dices.png"))
            picture = slide.Content.AddPicture(PictureContentType.Png, stream, 2, 2, 6, 5, LengthUnit.Centimeter);

        // Create "rounded rectangle" shape.
        var shape = slide.Content.AddShape(ShapeGeometryType.RoundedRectangle, 10, 2, 8, 5, LengthUnit.Centimeter);

        // Fill shape with picture content.
        var fillFormat = shape.Format.Fill.SetPicture(picture.Fill.Data.Content);

        // Set the offset of the edges of the stretched picture fill.
        fillFormat.StretchLeft   = 0.1;
        fillFormat.StretchRight  = 0.4;
        fillFormat.StretchTop    = 0.1;
        fillFormat.StretchBottom = 0.4;

        // Get shape outline format.
        var lineFormat = shape.Format.Outline;

        // Set shape red outline.
        lineFormat.Fill.SetSolid(Color.FromName(ColorName.Red));
        lineFormat.Width = Length.From(0.2, LengthUnit.Centimeter);

        presentation.Save("Pictures.pptx");
    }
    static void Main()
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        var presentation = new PresentationDocument();

        // Create new slide.
        var slide = presentation.Slides.AddNew(SlideLayoutType.Custom);

        // Create new text box.
        var textBox = slide.Content.AddTextBox(
            ShapeGeometryType.RoundedRectangle, 2, 2, 10, 20, LengthUnit.Centimeter);

        // Create new paragraph.
        var paragraph = textBox.AddParagraph();

        // Create new run.
        var run = paragraph.AddRun("All caps: ");

        run             = paragraph.AddRun("Capital letters");
        run.Format.Caps = CapsType.All;

        paragraph.AddLineBreak();

        run             = paragraph.AddRun("Bold: ");
        run             = paragraph.AddRun("Bold text");
        run.Format.Bold = true;

        paragraph.AddLineBreak();

        run = paragraph.AddRun("Italic: ");
        run = paragraph.AddRun("Italic text");
        run.Format.Italic = true;

        paragraph.AddLineBreak();

        run = paragraph.AddRun("Underline: ");
        run = paragraph.AddRun("Single underline text");
        run.Format.UnderlineStyle = UnderlineStyle.Single;

        paragraph.AddLineBreak();

        run             = paragraph.AddRun("Font size: ");
        run             = paragraph.AddRun("Font size is 14 points");
        run.Format.Size = Length.From(14, LengthUnit.Point);

        paragraph.AddLineBreak();

        run = paragraph.AddRun("Strikethrough: ");
        run = paragraph.AddRun("Some text");
        run.Format.Strikethrough = StrikethroughType.Single;

        paragraph.AddLineBreak();

        run = paragraph.AddRun("Double strikethrough: ");
        run = paragraph.AddRun("Some text");
        run.Format.Strikethrough = StrikethroughType.Double;

        paragraph.AddLineBreak();

        run = paragraph.AddRun("Font color: ");
        run = paragraph.AddRun("Red text");
        run.Format.Fill.SetSolid(Color.FromName(ColorName.Red));

        paragraph.AddLineBreak();

        run             = paragraph.AddRun("Font name: ");
        run             = paragraph.AddRun("Arial Black");
        run.Format.Font = "Arial Black";

        presentation.Save("Character Formatting.pptx");
    }
    static void Main()
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        var presentation = new PresentationDocument();

        // Create first presentation slide.
        var slide = presentation.Slides.AddNew(SlideLayoutType.Custom);

        // Create first shape.
        var shape = slide.Content.AddShape(ShapeGeometryType.Rectangle, 2, 2, 8, 3, LengthUnit.Centimeter);

        // Set shape outline format.
        shape.Format.Outline.Fill.SetSolid(Color.FromName(ColorName.DarkGray));

        // Create a paragraph.
        var paragraph = shape.Text.AddParagraph();

        // Add and format paragraph plain text.
        var run = paragraph.AddRun("Powered by ");

        run.Format.Fill.SetSolid(Color.FromName(ColorName.DarkGray));

        // Add and format paragraph hyperlink text.
        run = paragraph.AddRun("GemBox");
        run.Format.Fill.SetSolid(Color.FromName(ColorName.DarkRed));
        run.Format.Action.Click.Set(ActionType.HyperlinkToWebPage, "http://www.gemboxsoftware.com/");

        // Create second presentation slide.
        slide = presentation.Slides.AddNew(SlideLayoutType.Custom);

        // Create first shape.
        shape = slide.Content.AddShape(ShapeGeometryType.Rectangle, 2, 2, 4, 3, LengthUnit.Centimeter);

        // Set shape outline format.
        shape.Format.Outline.Fill.SetSolid(Color.FromName(ColorName.DarkGray));

        // Set text run.
        run = shape.Text.AddParagraph().AddRun("Play Sound");
        run.Format.Fill.SetSolid(Color.FromName(ColorName.DarkRed));

        // Set "play sound" action on created shape.
        var action = shape.Action.Click;

        using (var stream = File.OpenRead("Applause.wav"))
            action.PlaySound(stream, "applause.wav");

        action.Set(ActionType.None);
        action.Highlight = true;

        // Create second shape.
        shape = slide.Content.AddShape(ShapeGeometryType.Rectangle, 7, 2, 4, 3, LengthUnit.Centimeter);

        // Set shape outline format.
        shape.Format.Outline.Fill.SetSolid(Color.FromName(ColorName.DarkGray));

        // Set text run.
        run = shape.Text.AddParagraph().AddRun("Hyperlink To Previous Slide");
        run.Format.Fill.SetSolid(Color.FromName(ColorName.DarkRed));

        // Set "hyperlink to previous slide" action.
        shape.Action.Click.Set(ActionType.HyperlinkToPreviousSlide);

        // Create third shape.
        shape = slide.Content.AddShape(ShapeGeometryType.Rectangle, 12, 2, 4, 3, LengthUnit.Centimeter);

        // Set shape outline format.
        shape.Format.Outline.Fill.SetSolid(Color.FromName(ColorName.DarkGray));

        // Set text run.
        run = shape.Text.AddParagraph().AddRun("Hyperlink To Next Slide");
        run.Format.Fill.SetSolid(Color.FromName(ColorName.DarkRed));

        // Set "hyperlink to next slide" action.
        shape.Action.Click.Set(ActionType.HyperlinkToNextSlide);

        // Create forth shape.
        shape = slide.Content.AddShape(ShapeGeometryType.Rectangle, 17, 2, 4, 3, LengthUnit.Centimeter);

        // Set shape outline format.
        shape.Format.Outline.Fill.SetSolid(Color.FromName(ColorName.DarkGray));

        // Set text run.
        run = shape.Text.AddParagraph().AddRun("Hyperlink To Web Page");
        run.Format.Fill.SetSolid(Color.FromName(ColorName.DarkRed));

        // Set "hyperlink to web page" action.
        shape.Action.Click.Set(ActionType.HyperlinkToWebPage, "http://www.gemboxsoftware.com/");

        // Create third presentation slide.
        slide = presentation.Slides.AddNew(SlideLayoutType.Custom);

        presentation.Save("Hyperlinks.pptx");
    }
 private void SaveAndCloseDocument()
 {
     document.Save();
     document.Close();
 }
    static void Main()
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        var presentation = new PresentationDocument();

        // Create new presentation slide.
        var slide = presentation.Slides.AddNew(SlideLayoutType.Custom);

        int columnCount = 4;
        int rowCount    = 5;

        // Create new table.
        var table = slide.Content.AddTable(1, 1, 20, 4, LengthUnit.Centimeter);

        for (int i = 0; i < columnCount; i++)
        {
            // Create new table column.
            table.Columns.AddNew(Length.From(5, LengthUnit.Centimeter));
        }

        for (int i = 0; i < rowCount; i++)
        {
            // Create new table row.
            var row = table.Rows.AddNew(
                Length.From(8, LengthUnit.Millimeter));

            for (int j = 0; j < columnCount; j++)
            {
                // Create new table cell.
                row.Cells.AddNew().Text.AddParagraph().AddRun(
                    string.Format(null, "Cell {0}-{1}", i + 1, j + 1));
            }
        }

        // Set table style.
        table.Format.Style = presentation.TableStyles.GetOrAdd(
            TableStyleName.MediumStyle2Accent2);

        // Set table style options.
        table.Format.StyleOptions = TableStyleOptions.FirstRow
                                    | TableStyleOptions.LastRow
                                    | TableStyleOptions.BandedRows;

        // Create new table style.
        var myStyle = presentation.TableStyles.Create("My Table Styles");

        // Get "WholeTable" part style.
        var partStyle = myStyle[TablePartStyleType.WholeTable];

        // Set fill format.
        partStyle.Fill.SetSolid(Color.FromName(ColorName.LightGray));

        // Get table border style.
        var borderStyle = partStyle.Borders;

        // Get "InsideHorizontal" border format.
        var border = borderStyle[TableCellBorderType.InsideHorizontal];

        // Set border line format.
        border.Fill.SetSolid(Color.FromName(ColorName.DarkGray));
        border.Width = Length.From(2, LengthUnit.Millimeter);

        // Get "InsideVertical" border format.
        border = borderStyle[TableCellBorderType.InsideVertical];

        // Set border line format.
        border.Fill.SetSolid(Color.FromName(ColorName.DarkGray));
        border.Width = Length.From(2, LengthUnit.Millimeter);

        // Get "FirstRow" part style.
        partStyle = myStyle[TablePartStyleType.FirstRow];

        // Set fill format.
        partStyle.Fill.SetSolid(Color.FromName(ColorName.White));

        // Get table border style.
        borderStyle = partStyle.Borders;

        // Get "Top" border format.
        border = borderStyle[TableCellBorderType.Top];

        // Set border line format.
        border.Fill.SetSolid(Color.FromName(ColorName.Black));
        border.Width = Length.From(2, LengthUnit.Millimeter);

        // Get "Bottom" border format.
        border = borderStyle[TableCellBorderType.Bottom];

        // Set border line format.
        border.Fill.SetSolid(Color.FromName(ColorName.Black));
        border.Width = Length.From(2, LengthUnit.Millimeter);

        // Get table text style.
        var textStyle = partStyle.Text;

        // Set text format.
        textStyle.Bold  = true;
        textStyle.Color = Color.FromName(ColorName.DarkGray);

        // Get "LastRow" part style.
        partStyle = myStyle[TablePartStyleType.LastRow];

        // Set fill format.
        partStyle.Fill.SetSolid(Color.FromName(ColorName.White));

        // Get table border style.
        borderStyle = partStyle.Borders;

        // Set "Top" border line format.
        borderStyle[TableCellBorderType.Top].Fill.SetSolid(
            Color.FromName(ColorName.Black));

        borderStyle[TableCellBorderType.Top].Width =
            Length.From(2, LengthUnit.Millimeter);

        // Set "Bottom" border line format.
        borderStyle[TableCellBorderType.Bottom].Fill.SetSolid(
            Color.FromName(ColorName.Black));

        borderStyle[TableCellBorderType.Bottom].Width =
            Length.From(2, LengthUnit.Millimeter);

        // Set text format.
        partStyle.Text.Bold  = true;
        partStyle.Text.Color = Color.FromName(ColorName.DarkGray);

        // Create new table.
        table = slide.Content.AddTable(1, 8, 20, 4, LengthUnit.Centimeter);

        for (int i = 0; i < columnCount; i++)
        {
            // Create new table column.
            table.Columns.AddNew(Length.From(5, LengthUnit.Centimeter));
        }

        for (int i = 0; i < rowCount; i++)
        {
            // Create new table row.
            var row = table.Rows.AddNew(
                Length.From(8, LengthUnit.Millimeter));

            for (int j = 0; j < columnCount; j++)
            {
                // Create new table cell.
                row.Cells.AddNew().Text.AddParagraph().AddRun(
                    string.Format(null, "Cell {0}-{1}", i + 1, j + 1));
            }
        }

        // Set table style.
        table.Format.Style = myStyle;

        // Set table style options.
        table.Format.StyleOptions = TableStyleOptions.FirstRow
                                    | TableStyleOptions.LastRow;

        presentation.Save("Table Styles.pptx");
    }
    static void Main()
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        var presentation = new PresentationDocument();

        // Create new presentation slide.
        var slide = presentation.Slides.AddNew(SlideLayoutType.Custom);

        // Create first text box.
        var textBox = slide.Content.AddTextBox(ShapeGeometryType.RoundedRectangle, 2, 2, 8, 8, LengthUnit.Centimeter);

        // Set shape outline format.
        textBox.Shape.Format.Outline.Fill.SetSolid(Color.FromName(ColorName.DarkGray));

        // Create first paragraph with single run element.
        var run = textBox.AddParagraph().AddRun("Shows how to use text boxes with GemBox.Presentation component.");

        run.Format.Bold = true;

        // Create empty paragraph.
        textBox.AddParagraph();

        // Create (mixed-element) paragraph.
        var paragraph = textBox.AddParagraph();

        // Create and add a run element.
        run = paragraph.AddRun("Today's date: ");

        // Create and add a "DateTime" text field element.
        var field = paragraph.AddField(TextFieldType.DateTime);

        // Create empty paragraph.
        textBox.AddParagraph();

        // Create (multi-line) paragraph.
        paragraph = textBox.AddParagraph();

        // Create and add a first run element.
        run = paragraph.AddRun("This is a ...");

        // Create and add a line break element.
        var lb = paragraph.AddLineBreak();

        // Create and add a second run element.
        run = paragraph.AddRun("... multi-line paragraph.");

        // Create second text box.
        textBox = slide.Content.AddTextBox(ShapeGeometryType.RoundedRectangle, 12, 2, 8, 4, LengthUnit.Centimeter);

        // Set shape outline format.
        textBox.Shape.Format.Outline.Fill.SetSolid(Color.FromName(ColorName.DarkGray));

        // Create a list.
        paragraph = textBox.AddParagraph();
        run       = paragraph.AddRun("This is a paragraph list:");

        paragraph = textBox.AddParagraph();
        paragraph.Format.List.NumberType = ListNumberType.DecimalPeriod;
        run = paragraph.AddRun("First list item");

        paragraph = textBox.AddParagraph();
        paragraph.Format.List.NumberType = ListNumberType.DecimalPeriod;
        run = paragraph.AddRun("Second list item");

        paragraph = textBox.AddParagraph();
        paragraph.Format.List.NumberType = ListNumberType.DecimalPeriod;
        run = paragraph.AddRun("Third list item");

        presentation.Save("Text Boxes.pptx");
    }