Convert PDF to PowerPoint in .NET Smart Data Extractor

4 Nov 20266 minutes to read

PowerPoint (PPTX) is a presentation format used to create and edit slides. The Syncfusion® Smart Data Extractor library converts PDF files and images to PowerPoint in .NET, so you can edit the extracted text, tables, and images as slides.

Assemblies and NuGet packages required

Refer to the following links for the assemblies and NuGet packages required based on your target platform to convert PDF or Image as a PowerPoint file using the Syncfusion® Smart Data Extractor library.

Convert PDF or Image to PowerPoint Presentation

To convert a PDF document or Image into a PowerPoint using the ExtractDataAsPresentation method of the DataExtractor class, refer to the following code example:

using Syncfusion.SmartDataExtractor;
using Syncfusion.Presentation;

//Open the input PDF file as a stream.
using (FileStream stream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read))
{
  //Initialize the Data Extractor.
  DataExtractor extractor = new DataExtractor();
  //Extract data as IPresentation.
  IPresentation presentation = extractor.ExtractDataAsPresentation(stream);
  using MemoryStream saveStream = new MemoryStream();
  //Save the extracted PowerPoint data into an output file.
  presentation.Save(saveStream);
  presentation.Close();
}
using Syncfusion.SmartDataExtractor;
using Syncfusion.Presentation;

//Open the input PDF file as a stream.
using (FileStream stream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read))
{
  //Initialize the Data Extractor.
  DataExtractor extractor = new DataExtractor();
  //Extract data as IPresentation.
  IPresentation presentation = extractor.ExtractDataAsPresentation(stream);
  using MemoryStream saveStream = new MemoryStream();
  //Save the extracted PowerPoint data into an output file.
  presentation.Save(saveStream);
  presentation.Close();
}

If you want to convert an image instead of a PDF, replace the input stream with the image file (for example, Input.jpg or Input.png). The rest of the code remains unchanged.

You can download a complete working sample from GitHub.

Convert a range of PDF pages to PowerPoint

To convert a specific range of PDF pages from the PDF document into PowerPoint by using the ExtractDataAsPresentation method of the DataExtractor class, refer to the following code example:

using System.IO;
using Syncfusion.SmartDataExtractor;
using Syncfusion.Presentation;

//Open the input PDF file as a stream.
using (FileStream stream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read))
{
    //Initialize the Data Extractor.
    DataExtractor extractor = new DataExtractor();
    //Set the page range for conversion (example: pages 2 to 4).
    extractor.PageRange = new int[,] { { 2, 4 } };
    //Convert the selected pages into a PowerPoint presentation.
    IPresentation presentation = extractor.ExtractDataAsPresentation(stream);
    using MemoryStream saveStream = new MemoryStream();
    //Save the extracted PowerPoint data into an output file.
	presentation.Save(saveStream);
    presentation.Close();
}
using System.IO;
using Syncfusion.SmartDataExtractor;
using Syncfusion.Presentation;

//Open the input PDF file as a stream.
using (FileStream stream = new FileStream("Input.pdf", FileMode.Open, FileAccess.Read))
{
    //Initialize the Data Extractor.
    DataExtractor extractor = new DataExtractor();
    //Set the page range for conversion (example: pages 2 to 4).
    extractor.PageRange = new int[,] { { 2, 4 } };
    //Convert the selected pages to a PowerPoint presentation.
    IPresentation presentation = extractor.ExtractDataAsPresentation(stream);
    //Save the PowerPoint presentation.
    using MemoryStream saveStream = new MemoryStream();
    //Save the extracted PowerPoint data into an output file.
	presentation.Save(saveStream);
    presentation.Close();
}

If you want to convert an image instead of a PDF, replace the input stream with the image file (for example, Input.jpg or Input.png). The rest of the code remains unchanged.

Supported and Unsupported PDF Elements

The following table lists the PDF elements and their preservation details in the PowerPoint presentation.

PDF Elements Supported
Header, Footer, Title Yes
Text Yes
Image Yes
Table Yes
Nested Table No
Text Inline Styles Yes (Bold and Italic)
Subscript, Superscript Yes (Searchable PDF documents only)
Underline, Strikethrough No
List No (Converted as line-by-line text)
Charts and Barcodes Yes (Preserved as images)
Code blocks, Page Number Yes (Preserved as text)
Link No (Preserved as plain text)
Text color and Background color No
Logo in page header or footer No