Copy a Master Slide Introduction
With Aspose.Slides Cloud, you can copy a master slide from one PowerPoint presentation to another. The following method allows you to specify file names of the presentations and an index of the master slide to be copied. You can also apply the master slide to all presentation slides at once.
CopyMasterSlide
API
Type
Description
Resource
/slides/{name}/masterSlides
POST
Copies a master slide from one presentation to another.
CopyMasterSlide
Request Parameters
Name
Type
Location
Required
Description
name
string
path
true
The name of a destination presentation file.
cloneFrom
string
query
true
The name of a source presentation file.
cloneFromPosition
integer
query
true
The 1-based index of the master slide.
cloneFromPassword
string
header
false
The password to open the source presentation.
cloneFromStorage
string
query
false
The name of the storage containing the source presentation.
applyToAll
boolean
query
false
Specifies whether to apply the master slide to every presentation slide. False by default.
password
string
header
false
The password to open the destination presentation.
folder
string
query
false
The path to the folder containing the destination 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.
The related layout slides are automatically copied from the source presentation to the destination presentation.
Examples
Copy the first master slide from the document MyTemplates/MainTemplate.pptx to the document MyFolder/MyPresentation.pptx . Apply the master slide to all slides. The presentation files are saved to the default storage.
cURL Solution
Request
Get an Access Token
Copy curl POST "https://api.aspose.cloud/connect/token" \
-d "grant_type=client_credentials&client_id=MyClientId&client_secret=MyClientSecret" \
-H "Content-Type: application/x-www-form-urlencoded"
Copy the Master Slide
Copy curl -X POST "https://api.aspose.cloud/v3.0/slides/MyPresentation.pptx/masterSlides?cloneFrom=MyTemplates/MainTemplate.pptx&cloneFromPosition=1&applyToAll=true&folder=MyFolder" \
-H "authorization: Bearer MyAccessToken" \
-H "Content-Length: 0"
Response
Response Example
Copy {
"name" : "Custom Design" ,
"layoutSlides" : [
{
"href" : "https://api.aspose.cloud/v3.0/slides/MyPresentation.pptx/layoutSlides/4?folder=MyFolder" ,
"relation" : "self" ,
"title" : "Title Slide, Type: Title"
},
{
"href" : "https://api.aspose.cloud/v3.0/slides/MyPresentation.pptx/layoutSlides/5?folder=MyFolder" ,
"relation" : "self" ,
"title" : "Title and Content, Type: TitleAndObject"
}
],
"dependingSlides" : [
{
"href" : "https://api.aspose.cloud/v3.0/slides/MyPresentation.pptx/slides/1?folder=MyFolder" ,
"relation" : "self"
}
],
"selfUri" : {
"href" : "https://api.aspose.cloud/v3.0/slides/MyPresentation.pptx/masterSlides/3?folder=MyFolder" ,
"relation" : "self"
}
}
SDK Solutions
C#
Copy
using Aspose.Slides.Cloud.Sdk ;
using System ;
class Application
{
static void Main ( )
{
var slidesApi = new SlidesApi ( "MyClientId" , "MyClientSecret" );
var masterSlide = slidesApi . CopyMasterSlide ( "MyPresentation.pptx" , "MyTemplates/MainTemplate.pptx" , 1 , null , null , true , null , "MyFolder" );
Console . WriteLine ( $"Master slide name: {masterSlide.Name} " );
Console . WriteLine ( "\r\nTitles of the layout slides:" );
foreach ( var layoutSlide in masterSlide . LayoutSlides )
{
Console . WriteLine ( $"\t{layoutSlide.Title} " );
}
}
}
Java
Copy
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 ( "MyClientId" , "MyClientSecret" );
MasterSlide masterSlide = slidesApi . copyMasterSlide ( "MyPresentation.pptx" , "MyTemplates/MainTemplate.pptx" , 1 , null , null , true , null , "MyFolder" , null );
System . out . println ( "Master slide name: " + masterSlide . getName ());
System . out . println ( "\r\nTitles of the layout slides:" );
for ( ResourceUri layoutSlide : masterSlide . getLayoutSlides ()) {
System . out . println ( "\t" + layoutSlide . getTitle ());
}
}
}
PHP
Copy
use Aspose \Slides \Cloud \Sdk \Api \Configuration ;
use Aspose \Slides \Cloud \Sdk \Api \SlidesApi ;
$configuration = new Configuration ();
$configuration -> setAppSid ( "MyClientId" );
$configuration -> setAppKey ( "MyClientSecret" );
$slidesApi = new SlidesApi ( null , $configuration );
$masterSlide = $slidesApi -> copyMasterSlide ( "MyPresentation.pptx" , "MyTemplates/MainTemplate.pptx" , 1 , null , null , true , null , "MyFolder" );
echo "Master slide name: " , $masterSlide -> getName (), PHP_EOL ;
echo PHP_EOL , "Titles of the layout slides:" , PHP_EOL ;
foreach ( $masterSlide -> getLayoutSlides () as $layoutSlide ) {
echo " \t " , $layoutSlide -> getTitle (), PHP_EOL ;
}
Ruby
Copy
require "aspose_slides_cloud"
include AsposeSlidesCloud
configuration = AsposeSlidesCloud :: Configuration . new
configuration . app_sid = "MyClientId"
configuration . app_key = "MyClientSecret"
slides_api = AsposeSlidesCloud :: SlidesApi . new ( configuration )
master_slide = slides_api . copy_master_slide ( "MyPresentation.pptx" , "MyTemplates/MainTemplate.pptx" , 1 , nil , nil , true , nil , "MyFolder" )
puts "Master slide name: #{ master_slide . name } "
puts " \n Titles of the layout slides:"
for layout_slide in master_slide . layout_slides
puts " \t #{ layout_slide . title } "
end
Python
Copy
import asposeslidescloud
from asposeslidescloud.apis.slides_api import SlidesApi
slides_api = SlidesApi ( None , "MyClientId" , "MyClientSecret" )
master_slide = slides_api . copy_master_slide ( "MyPresentation.pptx" , "MyTemplates/MainTemplate.pptx" , 1 , None , None , True , None , "MyFolder" )
print ( f "Master slide name: {master_slide.name} \n " )
print ( "Titles of the layout slides:" )
for layout_slide in master_slide . layout_slides :
print ( f " \t {layout_slide.title} " )
Node.js
Copy
const cloud = require ( "asposeslidescloud" );
const slidesApi = new cloud . SlidesApi ( "MyClientId" , "MyClientSecret" );
slidesApi . copyMasterSlide ( "MyPresentation.pptx" , "MyTemplates/MainTemplate.pptx" , 1 , null , null , true , null , "MyFolder" ). then ( masterSlide => {
console . log ( "Master slide name: " , masterSlide . body . name );
console . log ( "\nTitles of the layout slides:" );
masterSlide . body . layoutSlides . forEach ( layoutSlide => {
console . log ( "\t" , layoutSlide . title );
});
});
C++
Copy
#include "asposeslidescloud/api/SlidesApi.h"
using namespace asposeslidescloud :: api ;
int main ()
{
auto slidesApi = std :: make_shared < SlidesApi > ( L "MyClientId" , L "MyClientSecret" );
auto masterSlide = slidesApi -> copyMasterSlide ( L "MyPresentation.pptx" , L "MyTemplates/MainTemplate.pptx" , 1 , L "" , L "" , true , L "" , L "MyFolder" ). get ();
std :: wcout << "Master slide name: " << masterSlide -> getName () << std :: endl ;
std :: wcout << std :: endl << "Titles of the layout slides:" << std :: endl ;
for ( auto layoutSlide : masterSlide -> getLayoutSlides ()) {
std :: wcout << " \t " << layoutSlide -> getTitle () << std :: endl ;
}
return 0 ;
}
Perl
Copy
use AsposeSlidesCloud::Configuration ;
use AsposeSlidesCloud::SlidesApi ;
my $config = AsposeSlidesCloud::Configuration -> new ();
$config -> { app_sid } = "MyClientId" ;
$config -> { app_key } = "MyClientSecret" ;
my $slides_api = AsposeSlidesCloud::SlidesApi -> new ( config => $config );
my %parameters = ( name => "MyPresentation.pptx" , clone_from => "MyTemplates/MainTemplate.pptx" , clone_from_position => 1 , apply_to_all => true , folder => "MyFolder" );
my $master_slide = $slides_api -> copy_master_slide ( %parameters );
print ( "Master slide name: $master_slide->{name}\n" );
print ( "\nTitles of the layout slides:\n" );
for my $layout_slide ( @ { $master_slide -> { layout_slides }}) {
print ( "\t$layout_slide->{title}\n" );
}
Swift
Go
SDKs
Check Available SDKs to learn how to add an SDK to your project.