Convert a Presentation and Get It in a Specified Format Introduction
The following method allows you to transfer a PowerPoint presentation from a local file to a Cloud Storage, convert the presentation to a desired format and obtain the result.
API
Type
Description
Resource
/slides/convert/{format}
POST
Converts a passed presentation to a specified format and returns the result of the conversion.
Convert
Request Parameters
Name
Type
Location
Required
Description
document
file
formData
true
The data of the presentation.
format
string
path
true
The desired format for the conversion.
password
string
header
false
The password to open the presentation.
storage
string
query
false
The name of the storage containing the external fonts.
fontsFolder
string
query
false
The path to the storage folder containing the external fonts.
slides
string
query
false
The 1-based indices of the slides to be converted. If it is not specified, all slides are converted by default.
options
object
body
false
The format-specific options for the conversion.
To use fontsFolder parameter, you can create storage folders and upload font files to them using Slides Cloud API.
You can convert parts of presentations using the optional slides parameter.
You can specify format-specific options using the options parameter.
cURL Examples
Create MyFonts storage folder in Main storage, add custom.ttf font to the folder, convert example.pptx presentation to PDF format, and save the PDF document to output.pdf file.
Requests
Creating the storage folder
Copy curl - X PUT "https://api.aspose.cloud/v3.0/slides/storage/folder/MyFonts?storageName=Main" \
- H "authorization: Bearer <access_token>" \
- H "Content-Length: 0" \
- H "accept: application/json"
Adding the font to the folder
Copy curl - X PUT "https://api.aspose.cloud/v3.0/slides/storage/file/MyFonts/custom.ttf?storageName=Main" \
- H "authorization: Bearer <access_token>" \
- H "Content-Type: application/octet-stream" \
-- data - binary @custom .ttf
Converting the presentation
Copy curl - X POST "https://api.aspose.cloud/v3.0/slides/convert/Pdf?storage=Main&fontsFolder=MyFonts" \
- H "authorization: Bearer <access_token>" \
- H "Content-Type: application/octet-stream" \
- H "accept: multipart/form-data" \
-- data - binary @example .pptx \
- o output . pdf
Responses
Creating the storage folder
no data
Adding the font to the folder
Copy {
"uploaded" : [
"custom.ttf"
],
"errors" : []
}
Converting the presentation
file data
SDK Source
Using an SDK (API client) is the quickest way for a developer to speed up the development. An SDK takes care of a lot of low-level details of making requests and handling responses and lets you focus on writing code specific to your particular project. The Aspose.Slides Cloud SDKs can be downloaded from the following page: Available SDKs
SDK Examples
Create MyFonts storage folder in Main storage, add custom.ttf font to the folder, convert example.pptx presentation to PDF format.
C#
Copy
using Aspose.Slides.Cloud.Sdk ;
using Aspose.Slides.Cloud.Sdk.Model ;
using System.IO ;
class Test
{
static void Main ( string [] args )
{
SlidesApi api = new SlidesApi ( "MyClientId" , "MyClientSecret" );
const string fontFolderName = "MyFonts" ;
const string fontFileName = "custom.ttf" ;
api . CreateFolder ( fontFolderName );
using var fontStream = File . OpenRead ( fontFileName );
api . UploadFile ( $"{fontFolderName} /{fontFileName} " , fontStream );
using var fileStream = File . OpenRead ( "example.pptx" );
using var responseStream = api . Convert ( fileStream , ExportFormat . Pdf , null , null , fontFolderName );
using var pdfStream = File . Create ( "output.pdf" );
responseStream . CopyTo ( pdfStream );
}
}
Java
Copy
import com.aspose.slides.ApiException ;
import com.aspose.slides.api.SlidesApi ;
import com.aspose.slides.model.ExportFormat ;
import java.io.IOException ;
import java.nio.file.Files ;
import java.nio.file.Paths ;
public class Main {
public static void main ( String [] args ) throws ApiException , IOException {
SlidesApi slidesApi = new SlidesApi ( "my_client_id" , "my_client_key" );
final String storageName = "Main" ;
final String fontFolderName = "MyFonts" ;
final String fontFileName = "custom.ttf" ;
slidesApi . createFolder ( fontFolderName , storageName );
byte [] fontData = Files . readAllBytes ( Paths . get ( "custom.ttf" ));
slidesApi . uploadFile ( fontFolderName + "/" + fontFileName , fontData , storageName );
byte [] fileData = Files . readAllBytes ( Paths . get ( "example.pptx" ));
File response = slidesApi . convert ( fileData , ExportFormat . PDF , null , storageName , fontFolderName , null , null );
System . out . println ( "The PDF file was saved to " + response . getPath ());
}
}
PHP
Copy
use Aspose \Slides \Cloud \Sdk \Api \Configuration ;
use Aspose \Slides \Cloud \Sdk \Api \SlidesApi ;
$configuration = new Configuration ();
$configuration -> setAppSid ( "my_client_id" );
$configuration -> setAppKey ( "my_client_key" );
$slidesApi = new SlidesApi ( null , $configuration );
$storageName = "Main" ;
$fontFolderName = "MyFonts" ;
$fontFileName = "custom.ttf" ;
$slidesApi -> createFolder ( $fontFolderName , $storageName );
$fontStream = fopen ( "custom.ttf" , "r" );
$slidesApi -> uploadFile ( $fontFolderName . "/" . $fontFileName , $fontStream , $storageName );
$fileStream = fopen ( "example.pptx" , "r" );
$response = $slidesApi -> convert ( $fileStream , "pdf" , null , $storageName , $fontFolderName , null , null );
print ( "The PDF file was saved to " . $response -> getPathname ());
Ruby
Copy
require 'aspose_slides_cloud'
configuration = AsposeSlidesCloud :: Configuration . new
configuration . app_sid = "my_client_id"
configuration . app_key = "my_client_key"
slides_api = AsposeSlidesCloud :: SlidesApi . new ( configuration )
storage_name = "Main"
font_folder_name = "MyFonts"
font_file_name = "custom.ttf"
slides_api . create_folder ( font_folder_name , storage_name )
font_data = File . binread ( "custom.ttf" )
slides_api . upload_file ( font_folder_name + "/" + font_file_name , font_data , storage_name )
file_data = File . binread ( "example.pptx" )
pdf_data = slides_api . convert ( file_data , "pdf" , nil , storage_name , font_folder_name )
File . binwrite ( "output.pdf" , pdf_data )
Python
Copy
import asposeslidescloud
from asposeslidescloud.apis.slides_api import SlidesApi
slides_api = SlidesApi ( None , "my_client_id" , "my_client_key" )
storage_name = "Main"
font_folder_name = "MyFonts"
font_file_name = "custom.ttf"
slides_api . create_folder ( font_folder_name , storage_name )
with open ( "custom.ttf" , "rb" ) as font_stream :
slides_api . upload_file ( font_folder_name + "/" + font_file_name , font_stream , storage_name )
with open ( "example.pptx" , "rb" ) as file_stream :
pdf_path = slides_api . convert ( file_stream , "pdf" , None , storage_name , font_folder_name )
print ( "The PDF file was saved to " + pdf_path )
Node.js
Copy
const cloud = require ( "asposeslidescloud" );
const fs = require ( "fs" );
const slidesApi = new cloud . SlidesApi ( "my_client_id" , "my_client_key" );
const storageName = "Main" ;
const fontFolderName = "MyFonts" ;
const fontFileName = "custom.ttf" ;
slidesApi . createFolder ( fontFolderName , storageName ). then (() => {
const fontStream = fs . createReadStream ( fontFileName );
slidesApi . uploadFile ( fontFolderName + "/" + fontFileName , fontStream , storageName ). then (() => {
const fileStream = fs . createReadStream ( "example.pptx" );
slidesApi . convert ( fileStream , "pdf" , null , storageName , fontFolderName ). then ( response => {
fs . writeFile ( "output.pdf" , response . body , ( error ) => {
if ( error ) throw error ;
});
});
});
});
Android
Copy
import com.aspose.slides.ApiException ;
import com.aspose.slides.api.SlidesApi ;
import com.aspose.slides.model.ExportFormat ;
import java.io.IOException ;
import java.nio.file.Files ;
import java.nio.file.Paths ;
public class Main {
public static void main ( String [] args ) throws ApiException , IOException {
SlidesApi slidesApi = new SlidesApi ( "my_client_id" , "my_client_key" );
final String storageName = "Main" ;
final String fontFolderName = "MyFonts" ;
final String fontFileName = "custom.ttf" ;
slidesApi . createFolder ( fontFolderName , storageName );
byte [] fontData = Files . readAllBytes ( Paths . get ( "custom.ttf" ));
slidesApi . uploadFile ( fontFolderName + "/" + fontFileName , fontData , storageName );
byte [] fileData = Files . readAllBytes ( Paths . get ( "example.pptx" ));
File response = slidesApi . convert ( fileData , ExportFormat . PDF , null , storageName , fontFolderName , null , null );
System . out . println ( "The PDF file was saved to " + response . getPath ());
}
}
C++
Copy
#include "asposeslidescloud/api/SlidesApi.h"
using namespace utility :: conversions ;
using namespace asposeslidescloud :: api ;
int main ()
{
auto slidesApi = std :: make_shared < SlidesApi > ( to_string_t ( "my_client_id" ), to_string_t ( "my_client_key" ));
auto storageName = to_string_t ( "Main" );
auto fontFolderName = to_string_t ( "MyFonts" );
auto fontFileName = to_string_t ( "custom.ttf" );
slidesApi -> createFolder ( fontFolderName , storageName ). get ();
auto fontStream = std :: make_shared < std :: ifstream > ( fontFileName , std :: ios :: binary );
auto fontContent = std :: make_shared < HttpContent > ();
fontContent -> setData ( fontStream );
auto fontFilePath = fontFolderName ;
fontFilePath . append ( to_string_t ( "/" )). append ( fontFileName );
slidesApi -> uploadFile ( fontFilePath , fontContent , storageName ). get ();
auto fileStream = std :: make_shared < std :: ifstream > ( "example.pptx" , std :: ios :: binary );
auto fileContent = std :: make_shared < HttpContent > ();
fileContent -> setData ( fileStream );
auto responseContent = slidesApi -> convert ( fileContent , to_string_t ( "pdf" ), utility :: string_t (), storageName , fontFolderName ). get ();
std :: ofstream pdfStream ( "output.pdf" , std :: ofstream :: binary ) ;
responseContent . writeTo ( pdfStream );
return 0 ;
}
Perl
Swift
Go
Copy
cfg := asposeslidescloud . NewConfiguration ()
cfg . AppSid = "my_client_id"
cfg . AppKey = "my_client_key"
api := asposeslidescloud . NewAPIClient ( cfg )
storageName := "Main"
fontFolderName := "customFonts"
fontFileName := "custom.ttf"
_ , e := api . SlidesApi . CreateFolder ( fontFolderName , storageName )
if e != nil {
fmt . Printf ( "Error: %v." , e )
return
}
fontData , e := ioutil . ReadFile ( fontFileName )
if e != nil {
fmt . Printf ( "Error: %v." , e )
return
}
_ , _ , e = api . SlidesApi . UploadFile ( fontFolderName + "/" + fontFileName , fontData , storageName )
if e != nil {
fmt . Printf ( "Error: %v." , e )
return
}
fileData , e := ioutil . ReadFile ( "example.pptx" )
if e != nil {
fmt . Printf ( "Error: %v." , e )
return
}
response , _ , e := api . SlidesApi . Convert ( fileData , "pdf" , "" , storageName , fontFolderName , nil , nil )
if e != nil {
fmt . Printf ( "Error: %v." , e )
}
fmt . Printf ( "The PDF file was saved to %v." , response . Name ())