Download a Shape from a Data Transfer Object Introduction
Aspose.Slides.Cloud RestAPI allows you to create a shape from a data transfer object and get an image of that shape.
The shape can be a chart, a table, a SmartArt figure or any other shape type supported by PowerPoint.
You don’t have to explicitly create a presentation to perform this action.
API
Type
Description
Resource
/slides/shape/{format}
POST
Creates the shape from the DTO and returns the result in the specified format.
DownloadShapeFromDto
Examples
cURL Example
The code examples below show how to generate an image from the shape model.
SDK Examples
C#
SlidesApi api = new SlidesApi ( "MyClientId" , "MyClientSecret" );
var dto = new Shape
{
ShapeType = GeometryShape . ShapeTypeEnum . Rectangle ,
Width = 400 ,
Height = 200 ,
Text = "New shape"
};
using Stream response = api . DownloadShapeFromDto ( ShapeExportFormat . Png , dto );
// Save the PNG document to a file.
using var outputFile = File . Create ( "output.png" );
response . CopyTo ( outputFile );
Java
SlidesApi api = new SlidesApi ( "MyClientId" , "MyClientSecret" );
Shape dto = new Shape ();
dto . setShapeType ( GeometryShape . ShapeTypeEnum . RECTANGLE );
dto . setWidth ( 400 . 0 );
dto . setHeight ( 200 . 0 );
dto . setText ( "New shape" );
File result = api . downloadShapeFromDto ( ShapeExportFormat . PNG , dto );
System . out . println ( "The PNG file was saved to " + result . getPath ());
PHP
use Aspose\Slides\Cloud\Sdk\Api\SlidesApi ;
use Aspose\Slides\Cloud\Sdk\Api\Configuration ;
use Aspose\Slides\Cloud\Sdk\Model\Shape ;
$config = new Configuration ();
$config -> setAppSid ( "MyClientId" );
$config -> setAppKey ( "MyClientSecret" );
$dto = new Shape ();
$dto -> setShapeType ( "Rectangle" );
$dto -> setWidth ( 400 );
$dto -> setHeight ( 200 );
$dto -> setText ( "Shape text" );
$api = new SlidesApi ( null , $config );
$result = $api -> downloadShapeFromDto ( "png" , $dto );
print ( "The PNG file was saved to " . $result -> getPathname ());
Ruby
configuration = AsposeSlidesCloud :: Configuration . new
configuration . app_sid = "MyClientId"
configuration . app_key = "MyClientSecret"
shape = AsposeSlidesCloud :: Shape . new
shape . shape_type = "Rectangle"
shape . width = 400
shape . height = 200
shape . text = "Shape text"
api = AsposeSlidesCloud :: SlidesApi . new ( configuration )
response = api . download_shape_from_dto ( AsposeSlidesCloud :: ShapeExportFormat :: PNG , shape )
# Save the PNG document to a file.
File . binwrite ( "output.png" , response )
Python
import asposeslidescloud
from asposeslidescloud.configuration import Configuration
from asposeslidescloud.apis.slides_api import SlidesApi
from asposeslidescloud.models.shape import Shape
configuration = Configuration ()
configuration . app_sid = 'MyClientId'
configuration . app_key = 'MyClientSecret'
api = SlidesApi ( configuration )
dto = Shape ()
dto . width = 400
dto . height = 200
dto . shape_type = "Rectangle"
dto . text = "Shape text"
with open ( "output.png" , "w" ) as f :
result = api . download_shape_from_dto ( "png" , dto )
print ( "The PNG file was saved to " + result )
Node.js
const CloudSdk = require ( "asposeslidescloud" );
const fs = require ( "fs" );
const api = new CloudSdk . SlidesApi ( "MyClientId" , "MyClientSecret" );
const dto = new CloudSdk . Shape ();
dto . shapeType = CloudSdk . GeometryShape . ShapeTypeEnum . Rectangle ;
dto . width = 400 ;
dto . height = 200 ;
dto . text = "Shape text" ;
const response = await api . downloadShapeFromDto ( CloudSdk . ShapeExportFormat . Png , dto );
fs . writeFile ( "shape.png" , response . body , ( error ) => {
if ( error ) throw error ;
});
Go
cfg := asposeslidescloud . NewConfiguration ()
cfg . AppSid = "MyClientId"
cfg . AppKey = "MyClientSecret"
api := asposeslidescloud . NewAPIClient ( cfg )
shape := asposeslidescloud . NewShape ()
shape . SetShapeType ( "Rectangle" )
shape . SetWidth ( 400 )
shape . SetHeight ( 200 )
shape . SetText ( "Shape text" )
result , _ , e := api . SlidesApi . DownloadShapeFromDto ( "png" , shape )
if e != nil {
fmt . Printf ( "Error: %v." , e )
return
}
fmt . Printf ( "The converted file was saved to %v." , result . Name ())
C++
Perl
use AsposeSlidesCloud::Configuration ;
use AsposeSlidesCloud::SlidesApi ;
use AsposeSlidesCloud::Object::Shape ;
my $config = AsposeSlidesCloud::Configuration -> new ();
$config -> { app_sid } = "MyClientId" ;
$config -> { app_key } = "MyClientSecret" ;
my $api = AsposeSlidesCloud::SlidesApi -> new ( config => $config );
my $dto = AsposeSlidesCloud::Object::Shape -> new ();
$dto -> { shape_type } = "Rectangle" ;
$dto -> { width } = 400 ;
$dto -> { height } = 200 ;
my %params = ( 'format' => "png" , 'dto' => $dto );
my $response = $api -> download_shape_from_dto ( %params );
Swift