All Projects → ShapeCrawler → ShapeCrawler

ShapeCrawler / ShapeCrawler

Licence: MIT License
A .NET library for manipulating PowerPoint presentations.

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to ShapeCrawler

Unioffice
Pure go library for creating and processing Office Word (.docx), Excel (.xlsx) and Powerpoint (.pptx) documents
Stars: ✭ 3,111 (+3435.23%)
Mutual labels:  powerpoint, ooxml, pptx
React Presents
React slideshow framework
Stars: ✭ 454 (+415.91%)
Mutual labels:  slide, presentation, powerpoint
Excelize
Golang library for reading and writing Microsoft Excel™ (XLSX) files.
Stars: ✭ 10,286 (+11588.64%)
Mutual labels:  openxml, ooxml
Docxtemplater
Generate docx pptx and xlsx (Microsoft Word, Powerpoint, Excel documents) from templates, from Node.js, the Browser and the command line / Demo: https://www.docxtemplater.com/demo
Stars: ✭ 1,990 (+2161.36%)
Mutual labels:  powerpoint, pptx
slides-presenter
Plugin to show slides and code examples directly from IntelliJ IDEs
Stars: ✭ 19 (-78.41%)
Mutual labels:  slide, presentation
Phppresentation
A pure PHP library for reading and writing presentations documents
Stars: ✭ 1,044 (+1086.36%)
Mutual labels:  presentation, powerpoint
Documentserver
ONLYOFFICE Document Server is an online office suite comprising viewers and editors for texts, spreadsheets and presentations, fully compatible with Office Open XML formats: .docx, .xlsx, .pptx and enabling collaborative editing in real time.
Stars: ✭ 2,335 (+2553.41%)
Mutual labels:  presentation, pptx
Pympress
Pympress is a simple yet powerful PDF reader designed for dual-screen presentations
Stars: ✭ 450 (+411.36%)
Mutual labels:  slide, presentation
Miniseminar
Confluence as a backend -> Express -> reveal.js as a presentation -> Profit!
Stars: ✭ 27 (-69.32%)
Mutual labels:  slide, presentation
Cppcon2015
Repository for the slides and the code of my CppCon 2015 talks.
Stars: ✭ 77 (-12.5%)
Mutual labels:  slide, presentation
cppcon2015
Repository for the slides and the code of my CppCon 2015 talks.
Stars: ✭ 93 (+5.68%)
Mutual labels:  slide, presentation
Kittik
Create slides in TypeScript and present them in the terminal using ASCII only!
Stars: ✭ 147 (+67.05%)
Mutual labels:  slide, presentation
slides
No description or website provided.
Stars: ✭ 27 (-69.32%)
Mutual labels:  slide, presentation
category-parametric-talk
Talks on category-parametric programming.
Stars: ✭ 22 (-75%)
Mutual labels:  presentation
CameraSlider
3D printed and smartphone controlled camera slider
Stars: ✭ 16 (-81.82%)
Mutual labels:  slide
APKenBurnsView
Ken Burns effect with face recognition!
Stars: ✭ 93 (+5.68%)
Mutual labels:  presentation
cyber-gym
Deliberately vulnerable scripts for Web Security training
Stars: ✭ 19 (-78.41%)
Mutual labels:  slide
DroidKaigi2019Presentation
The Flutter presentation that I made at the DroidKaigi conference
Stars: ✭ 23 (-73.86%)
Mutual labels:  presentation
VerificationCode
简单的滑动验证码JS插件 图片验证码
Stars: ✭ 15 (-82.95%)
Mutual labels:  slide
com.elovirta.ooxml
DITA to Word plug-in
Stars: ✭ 19 (-78.41%)
Mutual labels:  ooxml

ShapeCrawler

NuGet Nuget License

Project status: active

ShapeCrawler (formerly SlideDotNet) is a .NET library for manipulating PowerPoint presentations. It provides fluent APIs to process slides without having Microsoft Office installed.

This library provides a simplified object model on top of the Open XML SDK for manipulating PowerPoint documents.

Compatibility

  • .NET 5
  • .NET Core 3.1
  • .NET Framework 4.7.2+

Getting Started

To get started, install ShapeCrawler from NuGet:

dotnet add package ShapeCrawler

Usage

The usage samples below will take you through some work experience with the presentation object model.

Working with Texts

using System;
using System.Linq;
using ShapeCrawler;

public class TextSample
{
    public static void Text()
    {
        // Open presentation and get first slide
        using IPresentation presentation = SCPresentation.Open("helloWorld.pptx", isEditable: true);
        ISlide slide = presentation.Slides.First();

        // Get text holder auto shape
        IAutoShape autoShape = (IAutoShape)slide.Shapes.First(sp => sp is IAutoShape);

        // Change whole shape text
        autoShape.TextBox.Text = "A new shape text";

        // Change text for a certain paragraph
        IParagraph paragraph = autoShape.TextBox.Paragraphs[1];
        paragraph.Text = "A new text for second paragraph";

        // Get font name and size
        IPortion paragraphPortion = autoShape.TextBox.Paragraphs.First().Portions.First();
        Console.WriteLine($"Font name: {paragraphPortion.Font.Name}");
        Console.WriteLine($"Font size: {paragraphPortion.Font.Size}");

        // Set bold font
        paragraphPortion.Font.IsBold = true;

        // Get font ARGB color
        Color fontColor = paragraphPortion.Font.ColorFormat.Color;

        // Save changes presentation
        presentation.Save();
    }
}

Working with Tables

using System;
using System.Linq;
using ShapeCrawler;

public class TableSample
{
    public static void Table()
    {
        // Get first slide
        using IPresentation presentation = SCPresentation.Open("helloWorld.pptx", isEditable: false);
        ISlide slide = presentation.Slides.First();

        // Get table
        ITable table = (ITable)slide.Shapes.First(sp => sp is ITable);

        // Get number of rows in the table
        int rowsCount = table.Rows.Count;

        // Get number of cells in the first row
        int rowCellsCount = table.Rows[0].Cells.Count;

        // Print a message if the cell is a part of a merged cells group
        foreach (SCTableRow row in table.Rows)
        {
            foreach (ITableCell cellItem in row.Cells)
            {
                if (cellItem.IsMergedCell)
                {
                    Console.WriteLine("The cell is a part of a merged cells group.");
                }
            }
        }

        // Get column's width
        Column tableColumn = table.Columns[0];
        long columnWidth = tableColumn.Width;

        // Get row's height
        long rowHeight = table.Rows[0].Height;

        // Get cell with row index 0 and column index 1
        ITableCell cell = table[0, 1];

        // Merge cells
        table.MergeCells(table[0,0], table[0, 1]);

        // Save changes
        presentation.Save();
    }
}

Working with Pictures

using System.Linq;
using ShapeCrawler;

public class PictureSamples
{
    public static void Picture()
    {
        using IPresentation presentation = SCPresentation.Open("helloWorld.pptx", isEditable: true);

        // Get picture shape
        IPicture picture = presentation.Slides[0].Shapes.OfType<IPicture>().First();

        // Change image
        picture.Image.SetImage("new-image.png");

        // Save changes
        presentation.Save();
    }
}

Working with Audio

using System.IO;
using ShapeCrawler;

public class WorkingWithAudio
{
    public static void AddAudioShape()
    {
        // Add audio
        IPresentation presentation = SCPresentation.Open("helloWorld.pptx", isEditable: true);                
        IShapeCollection shapes = presentation.Slides[0].Shapes;
        using Stream mp3Stream = File.OpenRead("audio.mp3");
        IAudioShape addedAudioShape = shapes.AddNewAudio(xPixel: 300, yPixels: 100, mp3Stream);

        presentation.Save();
        presentation.Close();      
    }
}

Working with Charts

using System;
using System.Linq;
using ShapeCrawler;

public class ChartSample
{
    public static void Chart()
    {
        using IPresentation presentation = SCPresentation.Open("helloWorld.pptx", isEditable: true);
        ISlide slide = presentation.Slides.First();

        // Get chart
        IChart chart = (IChart)slide.Shapes.First(sp => sp is IChart);
        
        // Print chart title
        if (chart.HasTitle)
        {
            Console.WriteLine(chart.Title);
        }
        
        if (chart.Type == ChartType.BarChart)
        {
            Console.WriteLine("Chart type is BarChart.");
        }

        // Update category
        chart.Categories[0].Name = "Price";       
    }
}

Working with Slide Masters

using ShapeCrawler;

public class SlideMasterSample
{
    public static void SlideMaster()
    {
        // Open presentation in the read mode
        using IPresentation presentation = SCPresentation.Open("helloWorld.pptx", isEditable: false);

        // Get number of Slide Masters in the presentation
        int slideMastersCount = presentation.SlideMasters.Count;

        // Get first Slide Master
        ISlideMaster slideMaster = presentation.SlideMasters[0];

        // Get number of shapes in the Slide Master
        int masterShapeCount = slideMaster.Shapes.Count;
    }
}

Update slide collection

using System.Linq;
using ShapeCrawler;

public class UpdateSlideCollection
{
    public static void Update()
    {
        // Remove first slide
        using IPresentation presentation = SCPresentation.Open("test.pptx", true);
        ISlide removingSlide = presentation.Slides.First();
        presentation.Slides.Remove(removingSlide);

        // Move second slide to first position
        presentation.Slides[1].Number = 2;

        // Copy second slide from source into dest
        using IPresentation source = SCPresentation.Open("source.pptx", true);
        using IPresentation dest = SCPresentation.Open("dest.pptx", true);
        ISlide copyingSlide = presentation.Slides[1];
        dest.Slides.Add(copyingSlide);

        // Save changes
        presentation.Save();
    }
}

More samples

Check /samples/ShapeCrawler.Samples folder to see more usage samples.

Feedback and Give a Star!

The project is in development, and I’m pretty sure there are still lots of things to add in this library. Try it out and let me know your thoughts.

Feel free to submit a ticket if you find bugs. Your valuable feedback is much appreciated to improve this project better. If you find this useful, please give it a star to show your support.

Contributing and Support

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].