Delete Shapes from a Group Shape Introduction
This article shows you how to delete shapes from a group shape using Aspose.Slides Cloud API in your applications. DeleteShape method has an optional subShape parameter that allows to specify path to the sub-shape to be deleted. The sub-shape path is a string that contains shape index (e.g., “1”) or a path in case of more than one level of grouping (e.g. “1/shapes/1”).
Examples
The second slide in MyFolder/MyPresentation.pptx document contains a single shape. The shape is a group shape consisting of four shapes. Delete the third shape from the group.
cURL Solution
Request
Get an Access Token
Copy curl -X 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"
Delete the Shape
Copy curl -X DELETE "https://api.aspose.cloud/v3.0/slides/MyPresentation.pptx/slides/2/shapes/1?folder=MyFolder&subShape=3" \
-H "authorization: Bearer MyAccessToken"
Response
Response Example
Copy {
"shapesLinks" : [
{
"href" : "https://api.aspose.cloud/v3.0/slides/MyPresentation.pptx/slides/2/shapes/1/shapes/1?folder=MyFolder" ,
"relation" : "self" ,
"slideIndex" : 2
},
{
"href" : "https://api.aspose.cloud/v3.0/slides/MyPresentation.pptx/slides/2/shapes/1/shapes/2?folder=MyFolder" ,
"relation" : "self" ,
"slideIndex" : 2
},
{
"href" : "https://api.aspose.cloud/v3.0/slides/MyPresentation.pptx/slides/2/shapes/1/shapes/3?folder=MyFolder" ,
"relation" : "self" ,
"slideIndex" : 2
}
],
"selfUri" : {
"href" : "https://api.aspose.cloud/v3.0/slides/MyPresentation.pptx/slides/2/shapes/1/shapes?folder=MyFolder" ,
"relation" : "self" ,
"slideIndex" : 2 ,
"shapeIndex" : 1
}
}
SDK Solutions
C#
Copy
using Aspose.Slides.Cloud.Sdk ;
using System ;
class Application
{
static void Main ( )
{
var slidesApi = new SlidesApi ( "MyClientId" , "MyClientSecret" );
var remainingShapes = slidesApi . DeleteShape ( "MyPresentation.pptx" , 1 , 4 , null , "MyFolder" , null , "1" );
foreach ( var shape in remainingShapes . ShapesLinks )
{
Console . WriteLine ( shape . Href );
}
}
}
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" );
Shapes remainingShapes = slidesApi . deleteShape ( "MyPresentation.pptx" , 1 , 4 , null , "MyFolder" , null , "1" );
for ( ResourceUri shape : remainingShapes . getShapesLinks ())
{
System . out . println ( shape . getHref ());
}
}
}
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 );
$remainingShapes = $slidesApi -> deleteShape ( "MyPresentation.pptx" , 1 , 4 , null , "MyFolder" , null , "1" );
foreach ( $remainingShapes -> getShapesLinks () as $shape )
{
echo $shape -> getHref (), " \n " ;
}
Ruby
Copy
require "aspose_slides_cloud"
include AsposeSlidesCloud
configuration = Configuration . new
configuration . app_sid = "MyClientId"
configuration . app_key = "MyClientSecret"
slides_api = SlidesApi . new ( configuration )
remaining_shapes = slides_api . delete_shape ( "MyPresentation.pptx" , 1 , 4 , nil , "MyFolder" , nil , "1" )
for shape in remaining_shapes . shapes_links
puts shape . href
end
Python
Copy
import asposeslidescloud
from asposeslidescloud.apis.slides_api import SlidesApi
slides_api = SlidesApi ( None , "MyClientId" , "MyClientSecret" )
remaining_shapes = slides_api . delete_shape ( "MyPresentation.pptx" , 1 , 4 , None , "MyFolder" , None , "1" )
for shape in remaining_shapes . shapes_links :
print ( shape . href )
Node.js
Copy
const cloud = require ( "asposeslidescloud" );
const slidesApi = new cloud . SlidesApi ( "MyClientId" , "MyClientSecret" );
slidesApi . deleteShape ( "MyPresentation.pptx" , 1 , 4 , null , "MyFolder" , null , "1" ). then ( remainingShapes => {
remainingShapes . body . shapesLinks . forEach ( shape => {
console . log ( shape . href );
});
});
C++
Copy
#include "asposeslidescloud/api/SlidesApi.h"
using namespace asposeslidescloud :: api ;
int main ()
{
auto slidesApi = new SlidesApi ( L "MyClientId" , L "MyClientSecret" );
auto remainingShapes = slidesApi -> deleteShape ( L "MyPresentation.pptx" , 1 , 4 , L "" , L "MyFolder" , L "" , L "1" ). get ();
for ( auto shape : remainingShapes -> getShapesLinks ()) {
std :: wcout << shape -> getHref () << 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" , slide_index => 1 , shape_index => 4 , folder => "MyFolder" , sub_shape => "1" );
my $remaining_shapes = $slides_api -> delete_shape ( %parameters );
for $shape ( @ { $remaining_shapes -> { shapes_links }}) {
print $shape -> { href }, "\n" ;
}
Swift
Go
DeleteShapes
API
Type
Description
Resource
/slides/{name}/slides/{slideIndex}/shapes
DELETE
Deletes shapes.
DeleteShapes
Request Parameters
Name
Type
Location
Required
Description
name
string
path
true
The name of a presentation file.
slideIndex
integer
path
true
The 1-based index of the slide with the group shape.
shapes
string
query
false
The indices of the shapes to be deleted. Delete all by default.
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
.
subShape
string
query
false
Sub-shape path (e.g. “3”, “3/shapes/2)
In case of Amazon S3 storage folder path starts with Amazon S3 bucket name.
Examples
The second slide in MyFolder/MyPresentation.pptx document contains a single shape. The shape is a group shape consisting of four shapes. Delete the first and third shapes from the group.
cURL Solution
Request
Get an Access Token
Copy curl -X 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"
Delete the Shapes
Copy curl -X DELETE "https://api.aspose.cloud/v3.0/slides/MyPresentation.pptx/slides/2/shapes?subShape=1&shapes=1,3&folder=MyFolder" \
-H "authorization: Bearer MyAccessToken"
Response
Response Example
Copy {
"shapesLinks" : [
{
"href" : "https://api.aspose.cloud/v3.0/slides/MyPresentation.pptx/slides/2/shapes/1/shapes/1?folder=MyFolder" ,
"relation" : "self" ,
"slideIndex" : 2
},
{
"href" : "https://api.aspose.cloud/v3.0/slides/MyPresentation.pptx/slides/2/shapes/1/shapes/2?folder=MyFolder" ,
"relation" : "self" ,
"slideIndex" : 2
}
],
"selfUri" : {
"href" : "https://api.aspose.cloud/v3.0/slides/MyPresentation.pptx/slides/2/shapes/1/shapes?folder=MyFolder" ,
"relation" : "self" ,
"slideIndex" : 2 ,
"shapeIndex" : 1
}
}
SDK Solutions
C#
Copy
using Aspose.Slides.Cloud.Sdk ;
using System ;
using System.Collections.Generic ;
class Application
{
static void Main ( )
{
var slidesApi = new SlidesApi ( "MyClientId" , "MyClientSecret" );
var shapeIndices = new List < int > { 1 , 2 };
var remainingShapes = slidesApi . DeleteShapes ( "MyPresentation.pptx" , 1 , shapeIndices , null , "MyFolder" , null , "4" );
foreach ( var shape in remainingShapes . ShapesLinks )
{
Console . WriteLine ( shape . Href );
}
}
}
Java
Copy
import com.aspose.slides.ApiException ;
import com.aspose.slides.api.SlidesApi ;
import java.util.Arrays ;
public class Application {
public static void main ( String [] args ) throws ApiException {
SlidesApi slidesApi = new SlidesApi ( "MyClientId" , "MyClientSecret" );
ArrayList shapeIndices = new ArrayList ( Arrays . asList ( 1 , 2 ));
Shapes remainingShapes = slidesApi . deleteShapes ( "MyPresentation.pptx" , 1 , shapeIndices , null , "MyFolder" , null , "4" );
for ( ResourceUri shape : remainingShapes . getShapesLinks ()) {
System . out . println ( shape . getHref ());
}
}
}
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 );
$remainingShapes = $slidesApi -> deleteShapes ( "MyPresentation.pptx" , 1 , [ 1 , 2 ], null , "MyFolder" , null , "4" );
foreach ( $remainingShapes -> getShapesLinks () as $shape ) {
echo $shape -> getHref (), " \n " ;
}
Ruby
Copy
require "aspose_slides_cloud"
include AsposeSlidesCloud
configuration = Configuration . new
configuration . app_sid = "MyClientId"
configuration . app_key = "MyClientSecret"
slides_api = SlidesApi . new ( configuration )
remaining_shapes = slides_api . delete_shapes ( "MyPresentation.pptx" , 1 , [ 1 , 2 ] , nil , "MyFolder" , nil , "4" )
for shape in remaining_shapes . shapes_links
puts shape . href
end
Python
Copy
import asposeslidescloud
from asposeslidescloud.apis.slides_api import SlidesApi
slides_api = SlidesApi ( None , "MyClientId" , "MyClientSecret" )
remaining_shapes = slides_api . delete_shapes ( "MyPresentation.pptx" , 1 , [ 1 , 2 ], None , "MyFolder" , None , "4" )
for shape in remaining_shapes . shapes_links :
print ( shape . href )
Node.js
Copy
const cloud = require ( "asposeslidescloud" );
const slidesApi = new cloud . SlidesApi ( "MyClientId" , "MyClientSecret" );
slidesApi . deleteShapes ( "MyPresentation.pptx" , 1 , [ 1 , 2 ], null , "MyFolder" , null , "4" ). then ( remainingShapes => {
remainingShapes . body . shapesLinks . forEach ( shape => {
console . log ( shape . href );
});
});
C++
Copy
#include "asposeslidescloud/api/SlidesApi.h"
using namespace asposeslidescloud :: api ;
int main ()
{
auto slidesApi = new SlidesApi ( L "MyClientId" , L "MyClientSecret" );
auto remainingShapes = slidesApi -> deleteShapes ( L "MyPresentation.pptx" , 1 , { 1 , 2 }, L "" , L "MyFolder" , L "" , L "4" ). get ();
for ( auto shape : remainingShapes -> getShapesLinks ()) {
std :: wcout << shape -> getHref () << 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 @shape_indices = ( 1 , 2 );
my %parameters = ( name => "MyPresentation.pptx" , slide_index => 1 , shapes => \ @shape_indices , folder => "MyFolder" , sub_shape => "4" );
my $remaining_shapes = $slides_api -> delete_shapes ( %parameters );
for $shape ( @ { $remaining_shapes -> { shapes_links }}) {
print $shape -> { 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.