Convert Using a Custom Size Introduction
You can use conversion options to specify a custom slide size when converting presentations to other formats.
cURL Example
Convert MyPresentation.pptx file to 480x360 PNG images.
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 file to 480x360 PNG images.
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" );
var options = new ImageExportOptions { Width = 480 , Height = 360 };
using var presentationStream = File . OpenRead ( "MyPresentation.pptx" );
using var responseStream = api . Convert ( presentationStream , ExportFormat . Png , options : options );
using var outputStream = File . Create ( "MyPresentation.zip" );
responseStream . CopyTo ( outputStream );
}
}
Java
Copy
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 ;
public class Main {
public static void main ( String [] args ) throws IOException , ApiException {
SlidesApi slidesApi = new SlidesApi ( "my_client_id" , "my_client_key" );
ImageExportOptions options = new ImageExportOptions ();
options . setWidth ( 480 );
options . setHeight ( 360 );
byte [] presentationData = Files . readAllBytes ( Paths . get ( "MyPresentation.pptx" ));
File outputFile = slidesApi . convert ( presentationData , ExportFormat . PNG , null , null , null , null , options );
System . out . println ( "The file with images was saved to: " + outputFile . toPath ());
}
}
PHP
Copy
use Aspose \Slides \Cloud \Sdk \Api \Configuration ;
use Aspose \Slides \Cloud \Sdk \Api \SlidesApi ;
use Aspose \Slides \Cloud \Sdk \Model \ImageExportOptions ;
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 );
$options = new ImageExportOptions ();
$options -> setWidth ( 480 );
$options -> setHeight ( 360 );
$presentationFile = fopen ( "MyPresentation.pptx" , 'r' );
$outputFile = $slidesApi -> convert ( $presentationFile , ExportFormat :: PNG , null , null , null , null , $options );
print ( "The file with images was saved to " . $outputFile -> getPathname ());
Ruby
Copy
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 )
options = AsposeSlidesCloud :: ImageExportOptions . new
options . width = 480
options . height = 360
presentation_data = File . binread ( "MyPresentation.pptx" )
output_data = slides_api . convert ( presentation_data , ExportFormat :: PNG , nil , nil , nil , nil , options )
File . binwrite ( "MyPresentation.zip" , output_data )
Python
Copy
import asposeslidescloud
from asposeslidescloud.apis.slides_api import SlidesApi
from asposeslidescloud.models.image_export_options import ImageExportOptions
from asposeslidescloud.models.export_format import ExportFormat
slides_api = SlidesApi ( None , "my_client_id" , "my_client_key" )
options = ImageExportOptions ()
options . width = 480
options . height = 360
with open ( "MyPresentation.pptx" , "rb" ) as presentation_file :
output_path = slides_api . convert ( presentation_file . read (), ExportFormat . PNG , None , None , None , None , options )
print ( "The file with images was saved to: " + output_path )
Node.js
Copy
const cloud = require ( "asposeslidescloud" );
const fs = require ( "fs" );
const slidesApi = new cloud . SlidesApi ( "my_client_id" , "my_client_key" );
const options = new cloud . ImageExportOptions ();
options . width = 480 ;
options . height = 360 ;
const presentationStream = fs . createReadStream ( "MyPresentation.pptx" );
slidesApi . convert ( presentationStream , "png" , null , null , null , null , options ). then ( response => {
fs . writeFile ( "MyPresentation.zip" , response . body , ( error ) => {
if ( error ) throw error ;
});
});
Go
Copy
cfg := asposeslidescloud . NewConfiguration ()
cfg . AppSid = "my_client_id"
cfg . AppKey = "my_client_key"
api := asposeslidescloud . NewAPIClient ( cfg )
options := asposeslidescloud . NewImageExportOptions ()
options . Width = 480
options . Height = 360
source , e := ioutil . ReadFile ( "MyPresentation.pptx" )
if e != nil {
fmt . Printf ( "Error: %v." , e )
return
}
result , _ , e := api . SlidesApi . Convert ( source , "png" , "" , "" , "" , nil , options )
if e != nil {
fmt . Printf ( "Error: %v." , e )
return
}
fmt . Printf ( "The file with images was saved to %v." , result . Name ())
C++
Copy
#include "asposeslidescloud/api/SlidesApi.h"
#include "asposeslidescloud/model/ImageExportOptions.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 options = std :: make_shared < ImageExportOptions > ();
options -> setWidth ( 480 );
options -> setHeight ( 360 );
auto presentationStream = std :: make_shared < std :: ifstream > ( "MyPresentation.pptx" , std :: ios :: binary );
auto presentationContent = std :: make_shared < HttpContent > ();
presentationContent -> setData ( presentationStream );
auto responseContent = slidesApi -> convert (
presentationContent , to_string_t ( "png" ), utility :: string_t (), utility :: string_t (), utility :: string_t (), {}, options ). get ();
std :: ofstream outputStream ( "MyPresentation.zip" , std :: ofstream :: binary ) ;
responseContent . writeTo ( outputStream );
return 0 ;
}
Perl
Swift