Convert PDF to PowerPoint in C#

PDF to PPTX

Nutrient .NET SDK (formerly GdPicture.NET) includes the ability to convert any supported file type into PowerPoint.

To save a PDF to a PowerPoint presentation (PPTX), use the SaveAsPPTX method of the GdPictureDocumentConverter class. It uses the following parameter:

  • Stream, or the overload FilePath — A stream object where the current document is saved as a PPTX file. This stream object must be initialized before it can be sent into this method, and it should stay open for subsequent use. If the output stream isn’t open for both reading and writing, the method will fail, returning the GdPictureStatus.InvalidParameter status, which is the file path where the converted file will be saved. If the specified file already exists, it’ll be overwritten. You have to specify a full file path, including the file extension.

Note that the output stream should be open for both reading and writing and closed/disposed of by the user once processing is complete using the CloseDocument method.

How to convert PDF to PPTX

  1. Create a GdPictureDocumentConverter object.
  2. Load the source document by passing its path to the LoadFromFile method. This method accepts all supported file formats. However, only a PDF file can be converted into a PPTX (other input file formats will return GdPictureStatus.NotImplemented). If the source document isn’t a PDF, it can be converted to PDF first with GdPictureDocumentConverter.SaveAsPDF. Recommended: Specify the source document format with a member of the DocumentFormat enumeration.
  3. Save the PDF file as a PPTX using SaveAsPPTX.

The following example converts and saves a PDF document to a PPTX file (it can also be saved as a stream):

using GdPictureDocumentConverter converter = new();
GdPictureStatus status = converter.LoadFromFile("input.pdf");
if (status != GdPictureStatus.OK)
{
throw new Exception(status.ToString());
}
status = converter.SaveAsPPTX("output.pptx");
if (status != GdPictureStatus.OK)
{
throw new Exception(status.ToString());
}
Console.WriteLine("The input document has been converted to a pptx file");