Convert Selected Slides Introduction
You can convert parts of presentations using optional slides parameter. This parameter is a comma-separated list of slides that should be included in the output.
cURL Example
Convert MyPresentation.pptx presentation to MyPresentation.pdf document. The document should only contain the slides with indexes 2 and 4 .
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
Convert MyPresentation.pptx presentation to a PDF document. The document should only contain the slides with indexes 2 and 4 .
C#
// For complete examples and data files, please go to https://github.com/aspose-Slides-cloud/aspose-Slides-cloud-dotnet
using Aspose.Slides.Cloud.Sdk ;
using Aspose.Slides.Cloud.Sdk.Model ;
using System.Collections.Generic ;
using System.IO ;
class Test
{
static void Main ( string [] args )
{
SlidesApi api = new SlidesApi ( "MyClientId" , "MyClientSecret" );
using var fileStream = File . OpenRead ( "MyPresentation.pptx" );
using var resultStream = api . Convert ( fileStream , ExportFormat . Pdf , slides : new List < int > { 2 , 4 });
using var outputStream = File . Create ( "MyPresentation.pdf" );
resultStream . CopyTo ( outputStream );
}
}
Java
// For complete examples and data files, please go to https://github.com/aspose-Slides-cloud/aspose-Slides-cloud-java
import com.aspose.slides.ApiException ;
import com.aspose.slides.api.SlidesApi ;
import com.aspose.slides.model.* ;
import java.io.IOException ;
import java.nio.file.Files ;
import java.nio.file.Paths ;
import java.util.Arrays ;
public class Main {
public static void main ( String [] args ) throws ApiException , IOException {
SlidesApi slidesApi = new SlidesApi ( "my_client_id" , "my_client_key" );
byte [] fileData = Files . readAllBytes ( Paths . get ( "MyPresentation.pptx" ));
File response = slidesApi . convert ( fileData , ExportFormat . PDF , null , null , null , Arrays . asList ( 2 , 4 ), null );
System . out . println ( "The converted file was saved to " + response . getPath ());
}
}
PHP
// For complete examples and data files, please go to https://github.com/aspose-Slides-cloud/aspose-Slides-cloud-php
use Aspose\Slides\Cloud\Sdk\Api\Configuration ;
use Aspose\Slides\Cloud\Sdk\Api\SlidesApi ;
use Aspose\Slides\Cloud\Sdk\Model\ExportFormat ;
$configuration = new Configuration ();
$configuration -> setAppSid ( "my_client_id" );
$configuration -> setAppKey ( "my_client_key" );
$slidesApi = new SlidesApi ( null , $configuration );
$fileStream = fopen ( "MyPresentation.pptx" , 'r' );
$response = $slidesApi -> Convert ( $fileStream , ExportFormat :: PDF , null , null , null , [ 2 , 4 ]);
print ( "The converted file was saved to " . $response -> getPathname ());
Ruby
# For complete examples and data files, please go to https://github.com/aspose-Slides-cloud/aspose-Slides-cloud-ruby
require "aspose_slides_cloud"
include AsposeSlidesCloud
configuration = AsposeSlidesCloud :: Configuration . new
configuration . app_sid = "my_client_id"
configuration . app_key = "my_client_key"
slides_api = AsposeSlidesCloud :: SlidesApi . new ( configuration )
file_data = File . binread ( "MyPresentation.pptx" )
pdf_data = slides_api . convert ( file_data , ExportFormat :: PDF , nil , nil , nil , [ 2 , 4 ] )
File . binwrite ( "MyPresentation.pdf" , pdf_data )
Python
# For complete examples and data files, please go to https://github.com/aspose-Slides-cloud/aspose-Slides-cloud-python
import asposeslidescloud
from asposeslidescloud.apis.slides_api import SlidesApi
from asposeslidescloud.models.export_format import ExportFormat
slides_api = SlidesApi ( None , "my_client_id" , "my_client_key" )
with open ( "MyPresentation.pptx" , "rb" ) as file_stream :
pdf_path = slides_api . convert ( file_stream , ExportFormat . PDF , None , None , None , [ 2 , 4 ])
print ( "The converted file was saved to " + pdf_path )
Node.js
// For complete examples and data files, please go to https://github.com/aspose-Slides-cloud/aspose-Slides-cloud-nodejs
const cloud = require ( "asposeslidescloud" );
const fs = require ( "fs" );
const slidesApi = new cloud . SlidesApi ( "my_client_id" , "my_client_key" );
const fileStream = fs . createReadStream ( "MyPresentation.pptx" );
slidesApi . convert ( fileStream , "pdf" , null , null , null , [ 2 , 4 ]). then ( response => {
fs . writeFile ( "MyPresentation.pdf" , response . body , ( error ) => {
if ( error ) throw error ;
});
});
Android
// For complete examples and data files, please go to https://github.com/aspose-Slides-cloud/aspose-Slides-cloud-android
import com.aspose.slides.ApiException ;
import com.aspose.slides.api.SlidesApi ;
import com.aspose.slides.model.* ;
import java.io.IOException ;
import java.nio.file.Files ;
import java.nio.file.Paths ;
import java.util.Arrays ;
public class Main {
public static void main ( String [] args ) throws ApiException , IOException {
var slidesApi = new SlidesApi ( "my_client_id" , "my_client_key" );
var fileData = Files . readAllBytes ( Paths . get ( "MyPresentation.pptx" ));
var response = slidesApi . convert ( fileData , ExportFormat . PDF , null , null , null , Arrays . asList ( 2 , 4 ), null );
System . out . println ( "The converted file was saved to " + response . getPath ());
}
}
C++
// For complete examples and data files, please go to https://github.com/aspose-Slides-cloud/aspose-Slides-cloud-cpp
#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 fileStream = std :: make_shared < std :: ifstream > ( "MyPresentation.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 (), utility :: string_t (), utility :: string_t (), { 2 , 4 }). get ();
std :: ofstream pdfStream ( "MyPresentation.pdf" , std :: ofstream :: binary );
responseContent . writeTo ( pdfStream );
return 0 ;
}
Perl
Swift
Go
// For complete examples and data files, please go to https://github.com/aspose-Slides-cloud/aspose-Slides-cloud-go
cfg := asposeslidescloud . NewConfiguration ()
cfg . AppSid = "my_client_id"
cfg . AppKey = "my_client_key"
api := asposeslidescloud . NewAPIClient ( cfg )
source , e := ioutil . ReadFile ( "MyPresentation.pptx" )
if e != nil {
fmt . Printf ( "Error: %v." , e )
return
}
result , _ , e := api . SlidesApi . Convert ( source , "pdf" , "" , "" , "" , [] int32 { 2 , 4 }, nil )
if e != nil {
fmt . Printf ( "Error: %v." , e )
return
}
fmt . Printf ( "The converted file was saved to %v." , result . Name ())