1. Products
  2.   Presentation
  3.   .NET
  4.   NetOffice
 
  

Free .NET Library for Manipulating Presentation Documents

Read, Write, Manipulate & Convert Presentation files, add slides and shapes to existing PPT/PPTX files via Open Source .NET API.

NetOffice is an open source API, developed by Microsoft and distributed under Microsoft open source code of conduct to manipulate Presentation Documents

Using the API, you can add text, header, footer, end notes, footnotes, styles, themes, and more. It allows you to generate high-performance presentation documents and extract data from them. The API support various .NET platforms including, .NET 3.5, .NET 4.0, .NET 4.6, and .NET Standard 1.3.

Previous Next

Getting Started with NetOffice

First of all, you require to have .NET Framework 4.5 or above. After that, please download the repository manually from GitHub or install it from NuGet.

Installation  NetOffice from NuGet

 Install-Package NetOfficeFw.Presentation

Add Slides in PowerPoint using Free C# API

NetOffice allows .NET programmers to add slides in Microsoft PowerPoint files programmatically. In order to add slides in PowerPoint file first you need to initialize an PowerPoint.Application and turn off message boxes. After your PowerPoint application is started you can add a new presentation in it using PowerApplication.Presentations.Add() method. Finally, You can add slides in your presentations using Presentation.Slides.Add() method

Create Presentations & Add Slides to It via C# API

            // start powerpoint
            PowerPoint.Application powerApplication = new PowerPoint.Application();

            // create a utils instance, no need for but helpful to keep the lines of code low
            CommonUtils utils = new CommonUtils(powerApplication);

            // add a new presentation with two new slides
            PowerPoint.Presentation presentation = powerApplication.Presentations.Add(MsoTriState.msoTrue);
            PowerPoint.Slide slide1 = presentation.Slides.Add(1, PpSlideLayout.ppLayoutBlank);
            PowerPoint.Slide slide2 = presentation.Slides.Add(1, PpSlideLayout.ppLayoutBlank);

            // add shapes
            slide1.Shapes.AddShape(MsoAutoShapeType.msoShape4pointStar, 100, 100, 200, 200);
            slide2.Shapes.AddShape(MsoAutoShapeType.msoShapeDoubleWave, 200, 200, 200, 200);

            // change blend animation
            slide1.SlideShowTransition.EntryEffect = PpEntryEffect.ppEffectCoverDown;
            slide1.SlideShowTransition.Speed = PpTransitionSpeed.ppTransitionSpeedFast;

            slide2.SlideShowTransition.EntryEffect = PpEntryEffect.ppEffectCoverLeftDown;
            slide2.SlideShowTransition.Speed = PpTransitionSpeed.ppTransitionSpeedFast;

            // save the document
            string documentFile = utils.File.Combine(HostApplication.RootDirectory, "Example04", DocumentFormat.Normal); 
            presentation.SaveAs(documentFile);

            // close power point and dispose reference
            powerApplication.Quit();
            powerApplication.Dispose();

            // show end dialog
            HostApplication.ShowFinishDialog(null, documentFile);

Add Label, Line & Star in Presentations using Free C# API

NetOffice allows .NET programmers to add label, line & stars in Microsoft Presentation File programmatically. In order to add content in presentation file first you need to initialize an PowerPoint.Application and turn off message boxes and add new presentation using PowerApplication.Presentations.Add() method and add a new slide using presentation.Slides.Add() method. You can insert add label, line and star in your slide by using Slide.Shapes.AddLabel(), Slide.Shapes.AddLine(), and Slide.Shapes.AddShape(() method respectively.

Add Label, Line and Star in Presentations via C# API

// add a new presentation with one new slide
PowerPoint.Presentation presentation = powerApplication.Presentations.Add(MsoTriState.msoTrue);
PowerPoint.Slide slide = presentation.Slides.Add(1, PpSlideLayout.ppLayoutBlank);

// add a label
PowerPoint.Shape label = slide.Shapes.AddLabel(MsoTextOrientation.msoTextOrientationHorizontal, 10, 10, 600, 20);
label.TextFrame.TextRange.Text = "This slide and created Shapes are created by NetOffice example.";

// add a line
slide.Shapes.AddLine(10, 80, 700, 80);

// add a wordart
slide.Shapes.AddTextEffect(MsoPresetTextEffect.msoTextEffect9, "This a WordArt", "Arial", 20,
                                           MsoTriState.msoTrue, MsoTriState.msoFalse, 10, 150);

// add a star
slide.Shapes.AddShape(MsoAutoShapeType.msoShape24pointStar, 200, 200, 250, 250);

// save the document
string documentFile = utils.File.Combine(HostApplication.RootDirectory, "Example02", DocumentFormat.Normal); 
presentation.SaveAs(documentFile);
 English