Spire.Cloud.PowerPoint provides the DocumentApi interface, which can be used to save PowerPoint documents to other formats. To convert a whole PowerPoint document into PDF, PPT, PPTX, PPS, PPSX, XPS, ODP file format, use the convertPptToPath method under the this interface; to export each slide as an individual JPEG, PNG, GIF, BMP, PPS, ODP, PDF, XPS, PS, PCL or SVG file, use the SplitPpt method instead.
Example 1. Convert PowerPoint to PDF
using System;
using Spire.Cloud.Powerpoint.Sdk.Client;
using Spire.Cloud.Powerpoint.Sdk.Api;
using Spire.Cloud.Powerpoint.Sdk.Model;
namespace ConvertPptToPdf
{
class Program
{
static String appId = "App ID";
static String appKey = "App Key";
static String baseUrl = "https://api.cloudxdocs.com";
//Create a Configuration object based on App ID, App Key and base URL
static Configuration configuration = new Configuration(appId, appKey, baseUrl);
//Create a DocumentApi object
static DocumentApi documentApi = new DocumentApi(configuration);
static void Main(string[] args)
{
//Specify the source document name
string name = "sample.pptx";
//Specify the file format to which the source document will be converted
string format = ExportFormat.Pdf.ToString();
//Declare an ExportOptions variable and set it to null
ExportOptions options = null;
//Specify the original password, set to null if there is no password
string password = null;
//Use the default storage, set to null
string storage = null;
//Specify the folder where the source document is stored
string folder = "input";
//Specify the output document path
string destFilePath = "output/ToPdf.pdf";
//Call ConvertPptToPath method to convert PowerPoint to PDF
documentApi.ConvertPptToPath(name, destFilePath, format, options, password, storage, folder);
}
}
}
Example 2. Convert PowerPoint to Images
using System;
using Spire.Cloud.Powerpoint.Sdk.Client;
using Spire.Cloud.Powerpoint.Sdk.Api;
using Spire.Cloud.Powerpoint.Sdk.Model;
namespace ConvertPptToPng
{
class Program
{
static String appId = " App ID ";
static String appKey = "App Key";
static String baseUrl = " https://api.cloudxdocs.com";
//Create a Configuration object based on App ID, App Key and base URL
static Configuration configuration = new Configuration(appId, appKey, baseUrl);
//Create a DocumentApi object
static DocumentApi documentApi = new DocumentApi(configuration);
static void Main(string[] args)
{
//Specify the source document name
string name = "sample.pptx";
//Declare an ExportOptions variable and set it to null
ExportOptions options = null;
//Specify the file format to which the source document will be converted
string format = SlideExportFormat.Svg.ToString();
//Specify the width and height of the converted image
int? width = 800;
int? height = 450;
//Specify the slide range that will be converted (the slide index starts from 0)
int? from = 0;
int? to = 1;
//Specify the folder where the source document is stored
string destFolder = "output";
//Specify the original password, set to null if there is no password
string password = null;
//Use the default storage, set to null
string storage = null;
//Specify the folder where the source document is stored
string folder = "input";
//Call SplitPpt method to convert the selected slides into individual images
documentApi.SplitPpt(name, options, format, width, height, to, from, destFolder, password, storage, folder);
}
}
}