Spire.Presentation is a powerful and easy-to-use .NET component, especially designed for developers. Using Spire.Presentation you can generate, modify, convert, render, and print documents without installing Microsoft PowerPoint on your machine. In this document, I will introduce you how to create PowerPoint file and save it to stream. I also introduce you how to load PowerPoint file from stream. Check it below.

Create PowerPoint file and save it to Stream

Step 1: Create Presentation instance.

Presentation presentation = new Presentation();

Step 2: Set background image.

string ImageFile = "bg.png";
RectangleF rect = new RectangleF(0, 0, presentation.SlideSize.Size.Width, presentation.SlideSize.Size.Height);
presentation.Slides[0].Shapes.AppendEmbedImage(ShapeType.Rectangle, ImageFile, rect);
presentation.Slides[0].Shapes[0].Line.FillFormat.SolidFillColor.Color = Color.FloralWhite;

Step 3: Add text to PowerPoint document.

IAutoShape shape = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(50, 70, 450, 150));
shape.Fill.FillType = FillFormatType.None;
shape.ShapeStyle.LineColor.Color = Color.White;

//add text to shape
shape.TextFrame.Text = "This demo shows how to Create PowerPoint file and save it to Stream.";
shape.TextFrame.Paragraphs[0].TextRanges[0].Fill.FillType = FillFormatType.Solid;
shape.TextFrame.Paragraphs[0].TextRanges[0].Fill.SolidColor.Color = Color.Black;

Step 4: Save document to stream.

FileStream to_stream = new FileStream("To_stream.pptx", FileMode.Create);
presentation.SaveToFile(to_stream, FileFormat.Pptx2010);
to_stream.Close();

Preview the generated PowerPoint file:

Save and Load PowerPoint file to/from Stream

Load PowerPoint file from stream.

Step 1: Create Presentation instance.

Presentation presentationLoad = new Presentation();

Step 2: Load PowerPoint file from stream.

FileStream from_stream = File.OpenRead("sample.pptx");
presentationLoad.LoadFromStream(from_stream, FileFormat.Pptx2010);

Step 3: Save the document.

presentationLoad.SaveToFile("From_stream.pptx",FileFormat.Pptx2010);
from_stream.Dispose();

Preview the PowerPoint file:

Save and Load PowerPoint file to/from Stream

Full code:

[C#]
using Spire.Presentation;
using Spire.Presentation.Drawing;
using System.Drawing;
using System.IO;
namespace SavePPTtoStream
{
    class Program
    {
        static void Main(string[] args)
        {

            //A: create PowerPoint file and save it to stream
            Presentation presentation = new Presentation();

            //set background Image
            string ImageFile = "bg.png";
            RectangleF rect = new RectangleF(0, 0, presentation.SlideSize.Size.Width, presentation.SlideSize.Size.Height);
            presentation.Slides[0].Shapes.AppendEmbedImage(ShapeType.Rectangle, ImageFile, rect);
            presentation.Slides[0].Shapes[0].Line.FillFormat.SolidFillColor.Color = Color.FloralWhite;

            //append new shape
            IAutoShape shape = presentation.Slides[0].Shapes.AppendShape(ShapeType.Rectangle, new RectangleF(50, 70, 450, 150));
            shape.Fill.FillType = FillFormatType.None;
            shape.ShapeStyle.LineColor.Color = Color.White;

            //add text to shape
            shape.TextFrame.Text = "This demo shows how to Create PowerPoint file and save it to Stream.";
            shape.TextFrame.Paragraphs[0].TextRanges[0].Fill.FillType = FillFormatType.Solid;
            shape.TextFrame.Paragraphs[0].TextRanges[0].Fill.SolidColor.Color = Color.Black;

            //save to Stream
            FileStream to_stream = new FileStream("To_stream.pptx", FileMode.Create);
            presentation.SaveToFile(to_stream, FileFormat.Pptx2010);
            to_stream.Close();

            System.Diagnostics.Process.Start("To_stream.pptx");


            //B: Load PowerPoint file from Stream
            Presentation presentationLoad = new Presentation();

            //load PowerPoint file from stream
            FileStream from_stream = File.OpenRead("sample.pptx");
            presentationLoad.LoadFromStream(from_stream, FileFormat.Pptx2010);

            //save the document
            presentationLoad.SaveToFile("From_stream.pptx", FileFormat.Pptx2010);
            from_stream.Dispose();

            System.Diagnostics.Process.Start("From_stream.pptx");


        }
    }
}

If you couldn't successfully use Spire.Presentation, please refer Spire.Presentation Quick Start which can guide you quickly use Spire.Presentation.

How to Remove Page breaks in C#

2014-06-11 08:24:54 Written by support iceblue

In Word document, users can add new page break or remove existing page breaks. This sample shows how to remove page breaks from the word document by using Spire.Doc. Spire.Doc supports to remove the page breaks from the word document from the format of .docx, .doc, and RTF etc.

Firstly make sure Spire.Doc for .NET has been installed correctly and then add Spire.Doc.dll as reference in the downloaded Bin folder though the below path: ".. \Spire.Doc\Bin\NET4.0\ Spire.Doc.dll". Here comes to the details of how to remove page breaks in C#.

//Create a new word document and load from the file.
Document document = new Document();
document.LoadFromFile("sample.docx");

// Traverse every paragraph of the first section of the document
for (int j = 0; j < document.Sections[0].Paragraphs.Count; j++)
  {
   Paragraph p = document.Sections[0].Paragraphs[j];

// Traverse every child object of a paragraph
for (int i = 0; i < p.ChildObjects.Count; i++)
    {
     DocumentObject obj = p.ChildObjects[i];

//Find the page break object
 if (obj.DocumentObjectType == DocumentObjectType.Break)
    {
     Break b = obj as Break;

// Remove the page break object from paragraph
p.ChildObjects.Remove(b);

//save the document to file.
document.SaveToFile("result.docx");

Please check the effective screenshot:

How to Remove Page breaks in C#

Full codes:

using Spire.Doc;
using Spire.Doc.Documents;
namespace RemovePageBreak
{
    class Program
    {
        static void Main(string[] args)
        {
            Document document = new Document();
            document.LoadFromFile("sample.docx", FileFormat.Docx);
            for (int j = 0; j < document.Sections[0].Paragraphs.Count; j++)
            {
                Paragraph p = document.Sections[0].Paragraphs[j];
                for (int i = 0; i < p.ChildObjects.Count; i++)
                {
                    DocumentObject obj = p.ChildObjects[i];
                    if (obj.DocumentObjectType == DocumentObjectType.Break)
                    {
                        Break b = obj as Break;
                        p.ChildObjects.Remove(b);
                    }
                }
            }
            document.SaveToFile("result.docx", FileFormat.Docx);
            System.Diagnostics.Process.Start("result.docx");
        }
    }
}

Spire.Presentation is a powerful and easy-to-use .NET component, especially designed for developers. Using Spire.Presentation you can generate, modify, convert, render, and print documents without installing Microsoft PowerPoint on your machine. There is a document in our website introducing you how to insert table. And in this document, you will be introduced how to edit a table within a PPT document.

Step 1: Create a Presentation instance and load the file.

Presentation presentation = new Presentation();
presentation.LoadFromFile("table.pptx");

Step 2: Store the data used in replacement in string [].

string[] str = new string[] { "Germany", "Berlin", "Europe", "0152458", "20860000" };

Step 3: Get the table within the PPT document.

ITable table = null;
foreach (IShape shape in presentation.Slides[0].Shapes)
{
    if (shape is ITable)
    {
        table = (ITable) shape;
    }
}

Step 4: Fill in the third row with new data and set the HighlightColor.

for (int i = 0; i < table.ColumnsList.Count;i++ )
{
    //replace the data in cell
    table[i, 2].TextFrame.Text = str[i];

    //set the highlightcolor
    table[i, 2].TextFrame.TextRange.HighlightColor.Color = Color.BlueViolet;
}

Step 5: Set the style of the table.

table.StylePreset = TableStylePreset.LightStyle1Accent2;

Step 6: Save the document.

presentation.SaveToFile("result.pptx", FileFormat.Pptx2010);

Download and install Spire.Presentation for .NET and refer to below code to edit table within PPT document.

Screenshots and full code:

Before:

Edit Table in PowerPoint document

After:

Edit Table in PowerPoint document

[C#]
using Spire.Presentation;
using System.Drawing;

namespace EditTable
{

    class Program
    {

        static void Main(string[] args)
        {
            //create a PPT document
            Presentation presentation = new Presentation();

            presentation.LoadFromFile("table.pptx");

            //the data used in replacement
            string[] str = new string[] { "Germany", "Berlin", "Europe", "0152458", "20860000" };

            ITable table = null;

            //get the table in PPT document
            foreach (IShape shape in presentation.Slides[0].Shapes)
            {
                if (shape is ITable)
                {
                    table = (ITable)shape;

                    //change the style of table
                    table.StylePreset = TableStylePreset.LightStyle1Accent2;

                    for (int i = 0; i < table.ColumnsList.Count; i++)
                    {
                        //replace the data in cell
                        table[i, 2].TextFrame.Text = str[i];

                        //set the highlightcolor
                        table[i, 2].TextFrame.TextRange.HighlightColor.Color = Color.BlueViolet;
                    }
                }
            }

            //save the document
            presentation.SaveToFile("result.pptx", FileFormat.Pptx2010);
            System.Diagnostics.Process.Start("result.pptx");

        }

    }
}
[VB.NET]
Imports Spire.Presentation
Imports System.Drawing

Namespace EditTbale

	Class Program

		Private Shared Sub Main(args As String())
			'create a PPT document
			Dim presentation As New Presentation()

			presentation.LoadFromFile("table.pptx")

			'the data used in replacement
			Dim str As String() = New String() {"Germany", "Berlin", "Europe", "0152458", "20860000"}

			Dim table As ITable = Nothing

			'get the table in PPT document
			For Each shape As IShape In presentation.Slides(0).Shapes
				If TypeOf shape Is ITable Then
					table = DirectCast(shape, ITable)

					'change the style of table
					table.StylePreset = TableStylePreset.LightStyle1Accent2

					For i As Integer = 0 To table.ColumnsList.Count - 1
						'replace the data in cell
						table(i, 2).TextFrame.Text = str(i)

						'set the highlightcolor
						table(i, 2).TextFrame.TextRange.HighlightColor.Color = Color.BlueViolet
					Next
				End If
			Next

			'save the document
			presentation.SaveToFile("result.pptx", FileFormat.Pptx2010)
			System.Diagnostics.Process.Start("result.pptx")

		End Sub

	End Class
End Namespace

If you couldn't successfully use Spire.Presentation, please refer Spire.Presentation Quick Start which can guide you quickly use Spire.Presentation.

Set X dimension of Barcode

2014-06-06 06:53:23 Written by support iceblue

Spire.Barcode is a free .NET component specially designed for developers. It can generate many kinds of barcode such as EAN128, Codabar, DataMatrix, PostNet and so on. It can also scan the barcode images. X dimension is the measure of the narrowest bar in a barcode. Barcodes and scanners have different X dimensions, so they must be matched. Using Spire.Barcode, it is quiet an easy job to do this.

In this document, I will introduce you how to so.

Step 1: Create a BarcodeSettings instance.

BarcodeSettings setting = new BarcodeSettings();

Step 2: Set the data to render.

setting.Data = "58465157484";
setting.Data2D = "58465157484";

Step 3: Set the type of barcode to generate.

setting.Type = BarCodeType.UPCA;

Step 4: Set the value of X dimension.

setting.Unit = GraphicsUnit.Millimeter;
setting.X = 0.8F;

The property Unit specifies the measurement unit. In this sample, the measurement unit is millimeter.

Step 5: Generate barcode image using BarCodeGenerator.

BarCodeGenerator gen = new BarCodeGenerator(setting);
Image img = gen.GenerateImage();
img.Save("barcode.png");

Screenshot and Full Code:

Set X dimension of Barcode

[C#]
using Spire.Barcode;
using System.Drawing;


namespace SetXDimension
{
    class Program
    {
        static void Main(string[] args)
        {
            BarcodeSettings barsetting = new BarcodeSettings();

            //set the x dimension
            barsetting.X = 0.8f;
            barsetting.Unit = GraphicsUnit.Millimeter;

            barsetting.HasBorder = true;
            barsetting.BorderWidth = 0.5F;

            //set the data
            barsetting.Data = "58465157484";
            barsetting.Data2D = "58465157484";

            //generate UPCA barcode
            barsetting.Type = BarCodeType.UPCA;

            BarCodeGenerator bargenerator = new BarCodeGenerator(barsetting);
            Image barcodeimage = bargenerator.GenerateImage();
            barcodeimage.Save("barcode.png");

            System.Diagnostics.Process.Start("barcode.png");
        }
    }
}
[VB.NET]
Imports Spire.Barcode
Imports System.Drawing


Namespace SetXDimension
	Class Program
		Private Shared Sub Main(args As String())
			Dim barsetting As New BarcodeSettings()

			'set the x dimension
			barsetting.X = 0.8F
			barsetting.Unit = GraphicsUnit.Millimeter

			barsetting.HasBorder = True
			barsetting.BorderWidth = 0.5F

			'set the data
			barsetting.Data = "58465157484"
			barsetting.Data2D = "58465157484"

			'generate UPCA barcode
			barsetting.Type = BarCodeType.UPCA

			Dim bargenerator As New BarCodeGenerator(barsetting)
			Dim barcodeimage As Image = bargenerator.GenerateImage()
			barcodeimage.Save("barcode.png")

			System.Diagnostics.Process.Start("barcode.png")
		End Sub
	End Class
End Namespace

Blank pages in PDFs are not uncommon to find because they may have been left intentionally by the author or added accidentally when manipulating documents. These blank pages can be annoying when you are reading or printing the document, so it may be quite necessary to remove them. In this article you will learn how to programmatically find and remove blank pages from PDF documents using Spire.PDF for .NET.

Install Spire.PDF for .NET

To begin with, you need to add the DLL files included in the Spire.PDF for.NET package as references in your .NET project. The DLLs files can be either downloaded from this link or installed via NuGet.

PM> Install-Package Spire.PDF

Find and Delete Blank Pages from a PDF Document

Spire.PDF for .NET provides a method PdfPageBase.IsBlank() to detect if a PDF page is absolutely blank. But some pages that look blank actually contain white images, these pages won't be deemed as blank using the PdfPageBase.IsBlank() method. Therefore, it is necessary to create a custom method IsImageBlank() to be used in conjunction with PdfPageBase.IsBlank() method to detect these white but non-blank pages.

Note: This solution will convert PDF pages into images and detect if an image is blank. It is necessary to apply a license to remove the evaluation message in the converted images. Otherwise, this method won't work properly. If you do not have a license, contact sales@e-iceblue.com for a temporary one for evaluation purpose.

The detailed steps are as follows:

  • Create a PdfDocument instance.
  • Load a PDF document using PdfDocument.LoadFromFile() method.
  • Loop through the pages in the PDF document to detect if the pages are blank using PdfPageBase.IsBlank() method.
  • For absolutely blank pages, delete them using PdfDocument.Pages.RemoveAt() method.
  • For pages that are not absolutely blank, save them as images using PdfDocument.SaveAsImage() method. Then detect if the converted images are blank using custom method IsImageBlank() and remove the pages that are "blank" using PdfDocument.Pages.RemoveAt() method.
  • Save the result document using PdfDocument.SaveToFile() method.
  • C#
  • VB.NET
using Spire.Pdf;
using Spire.Pdf.Graphics;
using System.Drawing;

namespace DeleteBlankPage
{
    class Program
    {
        static void Main(string[] args)
        {
            //Apply license by license key
            Spire.License.LicenseProvider.SetLicenseKey("your license key");

            //Create a PdfDocument instance
            PdfDocument document = new PdfDocument();

            //Load a sample PDF document
            document.LoadFromFile("input.pdf");

            //Loop through all pages in the PDF
            for (int i = document.Pages.Count - 1; i >= 0; i--)
            {
                //Detect if a page is blank
                if (document.Pages[i].IsBlank())
                {
                    //Remove the absolutely blank page
                    document.Pages.RemoveAt(i);
                }
                else
                {
                    //Save PDF page as image
                    Image image = document.SaveAsImage(i, PdfImageType.Bitmap);

                    //Detect if the converted image is blank
                    if (IsImageBlank(image))
                    {
                        //Remove the page
                        document.Pages.RemoveAt(i);
                    }
                }
            }

            //Save the result document
            document.SaveToFile("RemoveBlankPage.pdf", FileFormat.PDF);
        }

        //Detect if an image is blank
        public static bool IsImageBlank(Image image)
        {
            Bitmap bitmap = new Bitmap(image);
            for (int i = 0; i < bitmap.Width; i++)
            {
                for (int j = 0; j < bitmap.Height; j++)
                {
                    Color pixel = bitmap.GetPixel(i, j);
                    if (pixel.R < 240 || pixel.G < 240 || pixel.B < 240)
                    {
                        return false;
                    }
                }
            }
            return true;
        }
    }
}

C#/VB.NET: Find and Remove Blank Pages from PDF

Apply for a Temporary License

If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.

Images are one of the most common elements in PowerPoint presentations. There may be times when you need to extract images from specific presentation slides or from an entire presentation, for example, when you want to reuse those images in another presentation. In this article, you will learn how to extract images from PowerPoint presentations in C# and VB.NET using Spire.Presentation for .NET library.

Install Spire.Presentation for .NET

To begin with, you need to add the DLL files included in the Spire.Presentation for.NET package as references in your .NET project. The DLL files can be either downloaded from this link or installed via NuGet.

PM> Install-Package Spire.Presentation

Extract Images from an Entire Presentation in C# and VB.NET

To extract images from an entire PowerPoint presentation, you need to use the Presentation.Images property to get the collection of all the images in the presentation, then iterate through the collection and call ImageCollection[int].Image.Save() method to save each image to an image file. The following are the detailed steps:

  • Initialize an instance of the Presentation class.
  • Load a PowerPoint presentation using Presentation.LoadFromFile() method.
  • Get the collection of all the images in the presentation through Presentation.Images property.
  • Iterate through the collection, and call ImageCollection[int].Image.Save() method to save the images in the collection to image files.
  • C#
  • VB.NET
using Spire.Presentation;
using Spire.Presentation.Collections;
using System.Drawing;

namespace ExtractImagesFromPresentation
{
    internal class Program
    {
        static void Main(string[] args)
        {
            //Initialize an instance of the Presentation class
            Presentation ppt = new Presentation();
            //Load a PowerPoint presentation
            ppt.LoadFromFile(@"Template.pptx");

            //Get the image collection of the presentation
            ImageCollection imageCollection = ppt.Images;

            //Iterate through the images in the collection
            for (int i = 0; i < imageCollection.Count; i++)
            {
                //Extract the images 
                imageCollection[i].Image.Save(string.Format(@"Presentation\Images{0}.png", i));
            }

            ppt.Dispose();
        }
    }
}

C#/VB.NET: Extract Images from PowerPoint Presentations

Extract Images from a Specific Presentation Slide in C# and VB.NET

To extract images from a specific slide, you need to iterate through all shapes on the slide, find the shapes that are of SlidePicture or PictureShape type, then use the SlidePicture.PictureFill.Picture.EmbedImage.Image.Save() or PictureShape.EmbedImage.Image.Save() method to save the images to image files. The following are the detailed steps:

  • Initialize an instance of the Presentation class.
  • Load a PowerPoint presentation using Presentation.LoadFromFile() method.
  • Get a specific slide by its index through Presentation.Slides[int] property.
  • Iterate through all shapes on the slide.
  • Check if the shapes are of SlidePicture or PictureShape type. If the result is true, save the images to image files using SlidePicture.PictureFill.Picture.EmbedImage.Image.Save() or PictureShape.EmbedImage.Image.Save() method.
  • C#
  • VB.NET
using Spire.Presentation;

namespace ExtractImagesFromSlide
{
    internal class Program
    {
        static void Main(string[] args)
        {
            //Initialize an instance of the Presentation class
            Presentation ppt = new Presentation();
            //Load a PowerPoint presentation
            ppt.LoadFromFile(@"Template4.pptx");

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

            int i = 0;
            //Iterate through all shapes on the first slide
            foreach (IShape s in slide.Shapes)
            {
                //Check if the shape is of SlidePicture type
                if (s is SlidePicture)
                {
                    //Extract the image
                    SlidePicture ps = s as SlidePicture;
                    ps.PictureFill.Picture.EmbedImage.Image.Save(string.Format(@"Slide\Images{0}.png", i));
                    i++;
                }
                //Check if the shape is of PictureShape type
                if (s is PictureShape)
                {
                    //Extract the image
                    PictureShape ps = s as PictureShape;
                    ps.EmbedImage.Image.Save(string.Format(@"Slide\Images{0}.png", i));
                    i++;
                }
            }
        }
    }
}

C#/VB.NET: Extract Images from PowerPoint Presentations

Apply for a Temporary License

If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.

Superscripts or subscripts are characters positioned slightly above or below the normal line of text. They are commonly used in scientific formulas such as mathematical equations or chemical expressions. If you are creating a document containing scientific formulas, you most likely need to insert superscripts or subscripts. In this article, we will demonstrate how to insert superscripts and subscripts into Word in C# and VB.NET using Spire.Doc for .NET library.

Install Spire.Doc for .NET

To begin with, you need to add the DLL files included in the Spire.Doc for.NET package as references in your .NET project. The DLL files can be either downloaded from this link or installed via NuGet.

PM> Install-Package Spire.Doc

Insert Superscripts and Subscripts into Word using C# and VB.NET

The following are the main steps to insert a superscript or subscript into a Word document using Spire.Doc for .NET:

  • Create a Document instance.
  • Load a Word document using Document.LoadFromFile() method.
  • Get the specific section through Document.Sections[sectionIndex] property.
  • Add a paragraph to the section using Section.AddParagraph() method.
  • Add normal text to the paragraph using Paragraph.AppendText() method.
  • Add superscript or subscript text to the paragraph using Paragraph.AppendText() method.
  • Apply superscript or subscript formatting to the superscript or subscript text through TextRange.CharacterFormat.SubSuperScript property.
  • Save the result document using Document.SaveToFile() method.
  • C#
  • VB.NET
using Spire.Doc;
using Spire.Doc.Documents;
using Spire.Doc.Fields;

namespace InsertSuperscriptAndSubscript
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a Document instance
            Document document = new Document();
            //Load a Word document
            document.LoadFromFile("Sample.docx");

            //Get the first section
            Section section = document.Sections[0];

            //Add a paragraph to the section
            Paragraph paragraph = section.AddParagraph();

            //Add normal text to the paragraph
            paragraph.AppendText("E = mc");
            //Add superscript text to the paragraph
            TextRange superscriptText = paragraph.AppendText("2");
            //Apply superscript formatting to the superscript text
            superscriptText.CharacterFormat.SubSuperScript = SubSuperScript.SuperScript;

            //Start a new line
            paragraph.AppendBreak(BreakType.LineBreak);

            //Add normal text to the paragraph
            paragraph.AppendText("H");
            //Add subscript text to the paragraph
            TextRange subscriptText = paragraph.AppendText("2");
            //Apply subscript formatting to the subscript text
            subscriptText.CharacterFormat.SubSuperScript = SubSuperScript.SubScript;
            //Add normal text to the paragraph
            paragraph.AppendText("O");

            //Set font size for the text in the paragraph
            foreach (var item in paragraph.Items)
            {
                if (item is TextRange)
                {
                    TextRange textRange = item as TextRange;
                    textRange.CharacterFormat.FontSize = 36f;
                }
            }

            //Save the result document
            document.SaveToFile("InsertSuperscriptAndSubscript.docx", FileFormat.Docx2013);
        }
    }
}

C#/VB.NET: Insert Superscripts and Subscripts into Word

Apply for a Temporary License

If you'd like to remove the evaluation message from the generated documents, or to get rid of the function limitations, please request a 30-day trial license for yourself.

Sometimes, we may need to delete specific slide in a PowerPoint presentation due to any reason. This section will illustrate that how we can accomplish that task using Spire.Presentation for .NET.

As a matter of fact, it is quite easy and convenient to remove slides by only one line of core code if you have Spire.Presentation.Dll installed as a reference in your .NET project assemblies. Here is the method:

Step 1: Create an instance of presentation class and load PPT documents

Presentation presentation = new Presentation();
presentation.LoadFromFile("sample.pptx");

Step 2: Remove the second slide from the presentation by using its index position

presentation.Slides.RemoveAt(1);

Step 3: Save and review

presentation.SaveToFile("result.pptx",FileFormat.Pptx2010);
System.Diagnostics.Process.Start("result.pptx");

Original layout:

Remove Slides from a Presentation

Result:

Remove Slides from a Presentation

Full C# code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Spire.Presentation;

namespace RemoveSlide
{
    class Program
    {
        static void Main(string[] args)
        {
            Presentation presentation = new Presentation();
            presentation.LoadFromFile("sample.pptx");

            //remove the second slide
            presentation.Slides.RemoveAt(1);

             presentation.SaveToFile("result.pptx",FileFormat.Pptx2010);
            System.Diagnostics.Process.Start("result.pptx");
        }
    }
}

Text annotation is often used in PDF file to show readers the extra information of the item. By using Spire.PDF you can not only add a new annotation, edit an existing annotation, but also delete annotations from PDF file. In this article, we will introduce you how to delete a particular annotation and delete all the annotation at one time.

First, check the PDF document with annotations.

Delete Annotation from PDF files in C#

Here comes to the steps of how to remove the bookmarks in C#.

  • Download Spire.PDF for .NET and install it correctly. The Spire.PDF installation is clean, professional and wrapped up in a MSI installer.
  • Add Spire.Pdf.dll as reference in the downloaded Bin folder though the below path: "..\Spire.Pdf\Bin\NET4.0\ Spire.Pdf.dll".
  • Check the code snippet of how to delete the annotations. With Spire.PDF.NET, we can remove both the particular annotation and remove all the annotations.

The code snippet of remove the first annotation from PDF file:

PdfDocument document = new PdfDocument();
//load the pdf file
document.LoadFromFile("E-iceblue.pdf");

//remove the first annotation
document.Pages[0].Annotations.RemoveAt(1);

document.SaveToFile("result.pdf");
System.Diagnostics.Process.Start("result.pdf");

The effective screenshot of remove the first annotation:

Delete Annotation from PDF files in C#

The code snippet of remove all annotations from PDF file:

PdfDocument document = new PdfDocument();
//load the pdf file
document.LoadFromFile("E-iceblue.pdf");

//remove all annotations
document.Pages[0].Annotations.Clear();

document.SaveToFile("result.pdf");
System.Diagnostics.Process.Start("result.pdf");

The effective screenshot of remove all the annotations:

Delete Annotation from PDF files in C#

In this document, I will introduce you how to add Spire. Barcode controls to Toolbox for Windows Forms application.

If you have already installed Spire.Barcode, you can add controls this way:

"Start" → "Programs" → "e-iceblue" → "Spire.Barcode": Click "Add Controls into VS Toolbox".

How to add Controls to Toolbox

Click "Add" to add controls.

How to add Controls to Toolbox

Right-click on the blank part of the Toolbox - "Add Ta" - name the new Tab "Spire Controls":

How to add Controls to Toolbox

Right-click on the blank part below "Spire Controls" → "Choose Items" → ".NET Framework Components" → "Browse" to the "Bin" folder → find the file "Spire.Barcode.dll" → "Open".

How to add Controls to Toolbox

Click "OK". Then you have added controls to Toolbox successfully.

How to add Controls to Toolbox

page 57