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
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
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
{
"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#
// 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 ()
{
var slidesApi = new SlidesApi ( "MyClientId" , "MyClientSecret" );
// Delete the shape from the group shape.
var remainingShapes = slidesApi . DeleteShape ( "MyPresentation.pptx" , 1 , 4 , null , "MyFolder" , null , "1" );
// Print resource references for the remaining shapes.
foreach ( var shape in remainingShapes . ShapesLinks )
{
Console . WriteLine ( shape . 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 ( "MyClientId" , "MyClientSecret" );
// Delete the shape from the group shape.
Shapes remainingShapes = slidesApi . deleteShape ( "MyPresentation.pptx" , 1 , 4 , null , "MyFolder" , null , "1" );
// Print resource references for the remaining shapes.
for ( ResourceUri shape : remainingShapes . getShapesLinks ())
{
System . out . println ( shape . 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 ( "MyClientId" );
$configuration -> setAppKey ( "MyClientSecret" );
$slidesApi = new SlidesApi ( null , $configuration );
// Delete the shape from the group shape.
$remainingShapes = $slidesApi -> deleteShape ( "MyPresentation.pptx" , 1 , 4 , null , "MyFolder" , null , "1" );
// Print resource references for the remaining shapes.
foreach ( $remainingShapes -> getShapesLinks () as $shape )
{
echo $shape -> 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 = Configuration . new
configuration . app_sid = "MyClientId"
configuration . app_key = "MyClientSecret"
slides_api = SlidesApi . new ( configuration )
# Delete the shape from the group shape.
remaining_shapes = slides_api . delete_shape ( "MyPresentation.pptx" , 1 , 4 , nil , "MyFolder" , nil , "1" )
# Print resource references for the remaining shapes.
for shape in remaining_shapes . shapes_links
puts shape . 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 , "MyClientId" , "MyClientSecret" )
# Delete the shape from the group shape.
remaining_shapes = slides_api . delete_shape ( "MyPresentation.pptx" , 1 , 4 , None , "MyFolder" , None , "1" )
# Print resource references for the remaining shapes.
for shape in remaining_shapes . shapes_links :
print ( shape . 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 ( "MyClientId" , "MyClientSecret" );
// Delete the shape from the group shape.
slidesApi . deleteShape ( "MyPresentation.pptx" , 1 , 4 , null , "MyFolder" , null , "1" ). then ( remainingShapes => {
remainingShapes . body . shapesLinks . forEach ( shape => {
// Print resource references for the remaining shapes.
console . log ( shape . href );
});
});
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 "MyClientId" , L "MyClientSecret" );
// Delete the shape from the group shape.
auto remainingShapes = slidesApi -> deleteShape ( L "MyPresentation.pptx" , 1 , 4 , L "" , L "MyFolder" , L "" , L "1" ). get ();
// Print resource references for the remaining shapes.
for ( auto shape : remainingShapes -> getShapesLinks ()) {
std :: wcout << shape -> 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 } = "MyClientId" ;
$config -> { app_key } = "MyClientSecret" ;
my $slides_api = AsposeSlidesCloud::SlidesApi -> new ( config => $config );
# Delete the shape from the group shape.
my %parameters = ( name => "MyPresentation.pptx" , slide_index => 1 , shape_index => 4 , folder => "MyFolder" , sub_shape => "1" );
my $remaining_shapes = $slides_api -> delete_shape ( %parameters );
# Print resource references for the remaining shapes.
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
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
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
{
"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#
// 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 ;
using System.Collections.Generic ;
class Application
{
static void Main ()
{
var slidesApi = new SlidesApi ( "MyClientId" , "MyClientSecret" );
// Delete the shapes from the group shape.
var shapeIndices = new List < int > { 1 , 2 };
var remainingShapes = slidesApi . DeleteShapes ( "MyPresentation.pptx" , 1 , shapeIndices , null , "MyFolder" , null , "4" );
// Print resource references for the remaining shapes.
foreach ( var shape in remainingShapes . ShapesLinks )
{
Console . WriteLine ( shape . 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 ;
import java.util.Arrays ;
public class Application {
public static void main ( String [] args ) throws ApiException {
SlidesApi slidesApi = new SlidesApi ( "MyClientId" , "MyClientSecret" );
// Delete the shapes from the group shape.
ArrayList shapeIndices = new ArrayList ( Arrays . asList ( 1 , 2 ));
Shapes remainingShapes = slidesApi . deleteShapes ( "MyPresentation.pptx" , 1 , shapeIndices , null , "MyFolder" , null , "4" );
// Print resource references for the remaining shapes.
for ( ResourceUri shape : remainingShapes . getShapesLinks ()) {
System . out . println ( shape . 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 ( "MyClientId" );
$configuration -> setAppKey ( "MyClientSecret" );
$slidesApi = new SlidesApi ( null , $configuration );
// Delete the shapes from the group shape.
$remainingShapes = $slidesApi -> deleteShapes ( "MyPresentation.pptx" , 1 , [ 1 , 2 ], null , "MyFolder" , null , "4" );
// Print resource references for the remaining shapes.
foreach ( $remainingShapes -> getShapesLinks () as $shape ) {
echo $shape -> 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 = Configuration . new
configuration . app_sid = "MyClientId"
configuration . app_key = "MyClientSecret"
slides_api = SlidesApi . new ( configuration )
# Delete the shapes from the group shape.
remaining_shapes = slides_api . delete_shapes ( "MyPresentation.pptx" , 1 , [ 1 , 2 ] , nil , "MyFolder" , nil , "4" )
# Print resource references for the remaining shapes.
for shape in remaining_shapes . shapes_links
puts shape . 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 , "MyClientId" , "MyClientSecret" )
# Delete the shapes from the group shape.
remaining_shapes = slides_api . delete_shapes ( "MyPresentation.pptx" , 1 , [ 1 , 2 ], None , "MyFolder" , None , "4" )
# Print resource references for the remaining shapes.
for shape in remaining_shapes . shapes_links :
print ( shape . 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 ( "MyClientId" , "MyClientSecret" );
// Delete the shapes from the group shape.
slidesApi . deleteShapes ( "MyPresentation.pptx" , 1 , [ 1 , 2 ], null , "MyFolder" , null , "4" ). then ( remainingShapes => {
remainingShapes . body . shapesLinks . forEach ( shape => {
// Print resource references for the remaining shapes.
console . log ( shape . href );
});
});
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 "MyClientId" , L "MyClientSecret" );
// Delete the shapes from the group shape.
auto remainingShapes = slidesApi -> deleteShapes ( L "MyPresentation.pptx" , 1 , { 1 , 2 }, L "" , L "MyFolder" , L "" , L "4" ). get ();
// Print resource references for the remaining shapes.
for ( auto shape : remainingShapes -> getShapesLinks ()) {
std :: wcout << shape -> 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 } = "MyClientId" ;
$config -> { app_key } = "MyClientSecret" ;
my $slides_api = AsposeSlidesCloud::SlidesApi -> new ( config => $config );
# Delete the shapes from the group shape.
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 );
# Print resource references for the remaining shapes.
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.