C#/VB.NET: Convert PowerPoint to Images (PNG, JPG, TIFF, EMF, SVG)

You may need to convert PowerPoint documents to images for various purposes, such as preventing other users from editing the contents of the PowerPoint documents, generating thumbnails for the PowerPoint documents, or sharing the PowerPoint documents on social media. In this article, you will learn how to convert PowerPoint documents to various image formats in C# and VB.NET using Spire.Presentation for .NET.

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

Convert PowerPoint Documents to JPG or PNG Images in C# and VB.NET

The following are the main steps to convert a PowerPoint document to JPG or PNG image:

  • Initialize an instance of Presentation class.
  • Load a PowerPoint document using Presentation.LoadFromFile() method.
  • Iterate through all slides in the PowerPoint document.
  • Save each slide as System.Drawing.Image object using ISlide.SaveAsImage() method.
  • Save the image object to PNG or JPG file using Image.Save() method.
  • C#
  • VB.NET
using Spire.Presentation;
using System.Drawing;

namespace ConvertPowerPointToJpgOrPngImage
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a Presentation instance
            Presentation presentation = new Presentation();
            //Load a PowerPoint document
            presentation.LoadFromFile(@"Sample.pptx");

            int i = 0;
            //Iterate through all slides in the PowerPoint document
            foreach(ISlide slide in presentation.Slides)
            {                 
                //Save each slide as PNG image
                Image image = slide.SaveAsImage();
                string fileName = string.Format("ToImage-img-{0}.png", i);
                image.Save(fileName, System.Drawing.Imaging.ImageFormat.Png);
                i++;
            }
        }
    }
}

C#/VB.NET: Convert PowerPoint to Images (PNG, JPG, TIFF, EMF, SVG)

Convert PowerPoint Documents to TIFF Images in C# and VB.NET

The following are the steps to convert a PowerPoint document to TIFF image:

  • Initialize an instance of Presentation class.
  • Load a PowerPoint document using Presentation.LoadFromFile() method.
  • Convert the PowerPoint document to TIFF image using Presentation.SaveToFile(string, FileFormat) method.
  • C#
  • VB.NET
using Spire.Presentation;

namespace ConvertPowerPointToTiffImage
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a Presentation instance
            Presentation presentation = new Presentation();
            //Load a PowerPoint document
            presentation.LoadFromFile(@"Sample.pptx");

            //Convert the PowerPoint document to TIFF image
            presentation.SaveToFile("toTIFF.tiff", FileFormat.Tiff);
        }
    }
}

C#/VB.NET: Convert PowerPoint to Images (PNG, JPG, TIFF, EMF, SVG)

Convert PowerPoint Documents to EMF Images in C# and VB.NET

The following are the steps to convert a PowerPoint document to EMF image:

  • Initialize an instance of Presentation class.
  • Load a PowerPoint document using Presentation.LoadFromFile() method.
  • Iterate through all slides in the PowerPoint document.
  • Save each slide to EMF image using ISlide.SaveAsEMF() method.
  • C#
  • VB.NET
using Spire.Presentation;

namespace ConvertPowerPointToEmfImage
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a Presentation instance
            Presentation presentation = new Presentation();
            //Load a PowerPoint document
            presentation.LoadFromFile(@"Sample.pptx");

            int i = 0;
            //Iterate through all slides in the PowerPoint document
            foreach (ISlide slide in presentation.Slides)
            {
                string fileName = string.Format("ToEmf-{0}.emf", i);
                //Save each slide to EMF image
                slide.SaveAsEMF(fileName);
                //Save each slide to EMF image with specified width and height
                //slide.SaveAsEMF(fileName, 1075, 710);
                i++;
            }
        }
    }
}

C#/VB.NET: Convert PowerPoint to Images (PNG, JPG, TIFF, EMF, SVG)

Convert PowerPoint Documents to SVG Images in C# and VB.NET

The following are the steps to convert a PowerPoint document to SVG images:

  • Initialize an instance of Presentation class.
  • Load a PowerPoint document using Presentation.LoadFromFile() method.
  • Convert the PowerPoint document to SVG and save the results into a queue of byte arrays using Presentation.SaveToSVG() method.
  • Iterate through the byte arrays in the queue.
  • At each iteration, remove and return the byte array at the beginning of the queue using Queue.Dequeue() method.
  • Initialize an instance of FileStream class and save the byte array to an SVG file using FileStream.Write() method.
  • C#
  • VB.NET
using Spire.Presentation;
using System.Collections.Generic;
using System.IO;

namespace ConvertPowerPointToSvgImage
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a Presentation instance
            Presentation presentation = new Presentation();
            //Load a PowerPoint document
            presentation.LoadFromFile(@"Sample.pptx");

            //Convert the PowerPoint document to SVG and save the results into a queue of byte arrays
            Queue svgBytes = presentation.SaveToSVG();
            int count = svgBytes.Count;
            //Iterate through the byte arrays in the queue
            for (int i = 0; i < count; i++)
            {
                //Remove and return the byte array at the beginning of the queue
                byte[] bt = svgBytes.Dequeue();
                //Specify the output file name
                string fileName = string.Format("ToSVG-{0}.svg", i);
                //Create a FileStream instance
                FileStream fs = new FileStream(fileName, FileMode.Create);
                //Save the byte array to a SVG file
                fs.Write(bt, 0, bt.Length);
            }
        }
    }
}

C#/VB.NET: Convert PowerPoint to Images (PNG, JPG, TIFF, EMF, SVG)

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.