Add a New Slide Introduction
This article shows you how to add new slides in PowerPoint presentations using Aspose.Slides for Cloud API in your applications. A presentation must be already saved to a storage. You can add a new slide at the end of the presentation or at a specified position. When creating a new slide, a layout can be applied immediately.
CreateSlide
API
Type
Description
Resource
/slides/{name}/slides
POST
Creates a new slide.
CreateSlide
Request Parameters
Name
Type
Location
Required
Description
name
string
path
true
The file name of a presentation.
layoutAlias
string
query
false
The alias of a layout slide for a new slide. The alias may be a layout slide type, a layout slide name, or an index.
position
integer
query
false
The 1-based index for the new slide. If the position is not specified, the slide will be added to the end.
password
string
header
false
The password to open the presentation.
folder
string
query
false
The path to the folder containing the presentation.
storage
string
query
false
The name of the storage contaning the folder
.
In case of Amazon S3 storage folder path starts with Amazon S3 bucket name.
Examples
MyFolder/MyPresentation.pptx document saved to MyStorage is containing two slides. Add a new slide at index 2 into the presentation and use the third layout for the new slide.
cURL Solution
SDK Solutions
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 System ;
class Application
{
static void Main ()
{
SlidesApi api = new SlidesApi ( "MyClientId" , "MyClientSecret" );
// Create a new slide.
var response = api . CreateSlide ( "MyPresentation.pptx" , "3" , 2 );
// Print links to all slides.
foreach ( var slide in response . SlideList )
{
// Output: https://api.aspose.cloud/v3.0/slides/MyPresentation.pptx/slides/1?folder=MyFolder etc.
Console . WriteLine ( slide . Href );
}
}
}
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 ;
public class Application {
public static void main ( String [] args ) throws ApiException {
SlidesApi slidesApi = new SlidesApi ( "my_client_id" , "my_client_secret" );
// Create a new slide.
Slides response = slidesApi . createSlide ( "MyPresentation.pptx" , "3" , 2 , null , "MyFolder" , "MyStorage" );
// Print links to all slides.
for ( ResourceUri slide : response . getSlideList ()) {
// Output: https://api.aspose.cloud/v3.0/slides/MyPresentation.pptx/slides/1?folder=MyFolder etc.
System . out . println ( slide . getHref ());
}
}
}
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 ;
$configuration = new Configuration ();
$configuration -> setAppSid ( "my_client_id" );
$configuration -> setAppKey ( "my_client_secret" );
$slidesApi = new SlidesApi ( null , $configuration );
// Create a new slide.
$response = $slidesApi -> createSlide ( "MyPresentation.pptx" , "3" , 2 , null , "MyFolder" , "MyStorage" );
// Print links to all slides.
foreach ( $response -> getSlideList () as $slide ) {
// Output: https://api.aspose.cloud/v3.0/slides/MyPresentation.pptx/slides/1?folder=MyFolder etc.
echo $slide -> getHref (), " \n " ;
}
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_secret"
slides_api = AsposeSlidesCloud :: SlidesApi . new ( configuration )
# Create a new slide.
response = slides_api . create_slide ( "MyPresentation.pptx" , "3" , 2 , nil , "MyFolder" , "MyStorage" )
# Print links to all slides.
for slide in response . slide_list
# Output: https://api.aspose.cloud/v3.0/slides/MyPresentation.pptx/slides/1?folder=MyFolder etc.
puts slide . href
end
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
slides_api = SlidesApi ( None , "my_client_id" , "my_client_secret" )
# Create a new slide.
response = slides_api . create_slide ( "MyPresentation.pptx" , "3" , 2 , None , "MyFolder" , "MyStorage" )
# Print links to all slides.
for slide in response . slide_list :
# Output: https://api.aspose.cloud/v3.0/slides/MyPresentation.pptx/slides/1?folder=MyFolder etc.
print ( slide . href )
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 slidesApi = new cloud . SlidesApi ( "my_client_id" , "my_client_secret" );
// Create a new slide.
slidesApi . createSlide ( "MyPresentation.pptx" , "3" , 2 , null , "MyFolder" , "MyStorage" ). then ( response => {
// Print links to all slides.
response . body . slideList . forEach ( slide => {
// Output: https://api.aspose.cloud/v3.0/slides/MyPresentation.pptx/slides/1?folder=MyFolder etc.
console . log ( slide . href );
});
});
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 ;
public class Application {
public static void main ( String [] args ) throws ApiException {
SlidesApi slidesApi = new SlidesApi ( "my_client_id" , "my_client_secret" );
// Create a new slide.
Slides response = slidesApi . createSlide ( "MyPresentation.pptx" , "3" , 2 , null , "MyFolder" , "MyStorage" );
// Print links to all slides.
for ( ResourceUri slide : response . getSlideList ()) {
// Output: https://api.aspose.cloud/v3.0/slides/MyPresentation.pptx/slides/1?folder=MyFolder etc.
System . out . println ( slide . getHref ());
}
}
}
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 asposeslidescloud :: api ;
int main ()
{
auto slidesApi = new SlidesApi ( L "my_client_id" , L "my_client_secret" );
// Create a new slide.
auto response = slidesApi -> createSlide ( L "MyPresentation.pptx" , L "3" , 2 , L "" , L "MyFolder" , L "MyStorage" ). get ();
// Print links to all slides.
for ( auto slide : response -> getSlideList ()) {
// Output: https://api.aspose.cloud/v3.0/slides/MyPresentation.pptx/slides/1?folder=MyFolder etc.
std :: wcout << slide -> getHref () << std :: endl ;
}
return 0 ;
}
Perl
# For complete examples and data files, please go to https://github.com/aspose-Slides-cloud/aspose-Slides-cloud-perl
use AsposeSlidesCloud::Configuration ;
use AsposeSlidesCloud::SlidesApi ;
my $config = AsposeSlidesCloud::Configuration -> new ();
$config -> { app_sid } = "my_client_id" ;
$config -> { app_key } = "my_client_secret" ;
my $slides_api = AsposeSlidesCloud::SlidesApi -> new ( config => $config );
# Create a new slide.
my %parameters = ( name => "MyPresentation.pptx" , layout_alias => "3" , position => 2 , folder => "MyFolder" , storage => "MyStorage" );
$response = $slides_api -> create_slide ( %parameters );
# Print links to all slides.
for my $slide ( @ { $response -> { slide_list }}) {
# Output: https://api.aspose.cloud/v3.0/slides/MyPresentation.pptx/slides/1?folder=MyFolder etc.
print $slide -> { href }, "\n" ;
}
Swift
Go
SDKs
Using an SDK (API client) is the quickest way for a developer to speed up 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. Check out our GitHub repository for a complete list of Aspose.Slides Cloud SDKs along with working examples, to get you started in no time. Please check Available SDKs article to learn how to add an SDK to your project.