Add Custom Properties Introduction
Aspose.Slides Cloud allows you to add document properties to a PowerPoint presentation. Document properties, also known as metadata, are details about a file that describe or identify it. They include details such as title, author name, subject, and keywords that identify the document’s topic or contents. This article shows you how to add one or more custom document properties.
SetDocumentProperties
API
Type
Description
Resource
/slides/{name}/documentproperties
POST
Adds a custom document property to a presentation.
SetDocumentProperties
Request Parameters
Name
Type
Location
Required
Description
name
string
path
true
The name of a presentation file.
properties
object
body
true
The list of new document properties to be added to the presentation.
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
Add the following custom properties to MyFolder/MyPresentation.pptx document saved to the default storage:
Name
Value
ProcessedByOffice
Scotland Team
MyProperty
My Value
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"
Add the Custom Properties
Copy curl -X POST "https://api.aspose.cloud/v3.0/slides/MyPresentation.pptx/documentproperties?folder=MyFolder" \
-H "authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-d @request_data.json
request_data.json content:
Copy {
"List" : [
{
"Name" : "ProcessedByOffice" ,
"Value" : "Scotland Team"
},
{
"Name" : "MyProperty" ,
"Value" : "My Value"
}
]
}
Response
Response Example
Copy {
"list" : [
{
"name" : "Author" ,
"value" : "Jhon Smith" ,
"builtIn" : true ,
"selfUri" : {
"href" : "https://api.aspose.cloud/v3.0/slides/MyPresentation.pptx/documentProperties/Author?folder=MyFolder" ,
"relation" : "self"
}
},
{
"name" : "Company" ,
"value" : "" ,
"builtIn" : true ,
"selfUri" : {
"href" : "https://api.aspose.cloud/v3.0/slides/MyPresentation.pptx/documentProperties/Company?folder=MyFolder" ,
"relation" : "self"
}
},
{
"name" : "CreatedTime" ,
"value" : "2022-07-13T14:01:41Z" ,
"builtIn" : true ,
"selfUri" : {
"href" : "https://api.aspose.cloud/v3.0/slides/MyPresentation.pptx/documentProperties/CreatedTime?folder=MyFolder" ,
"relation" : "self"
}
},
{
"name" : "MyProperty" ,
"value" : "My Value" ,
"builtIn" : false ,
"selfUri" : {
"href" : "https://api.aspose.cloud/v3.0/slides/MyPresentation.pptx/documentProperties/MyProperty?folder=MyFolder" ,
"relation" : "self"
}
},
{
"name" : "ProcessedByOffice" ,
"value" : "Scotland Team" ,
"builtIn" : false ,
"selfUri" : {
"href" : "https://api.aspose.cloud/v3.0/slides/MyPresentation.pptx/documentProperties/ProcessedByOffice?folder=MyFolder" ,
"relation" : "self"
}
}
],
"selfUri" : {
"href" : "https://api.aspose.cloud/v3.0/slides/MyPresentation.pptx/documentProperties?folder=MyFolder" ,
"relation" : "self"
}
}
SDK Solutions
C#
Copy
using Aspose.Slides.Cloud.Sdk ;
using Aspose.Slides.Cloud.Sdk.Model ;
using System.Collections.Generic ;
using System.Diagnostics ;
class Application
{
static void Main ( )
{
var slidesApi = new SlidesApi ( "MyClientId" , "MyClientSecret" );
var property1 = new DocumentProperty { Name = "ProcessedByOffice" , Value = "Scotland Team" };
var property2 = new DocumentProperty { Name = "MyProperty" , Value = "My Value" };
var newProperties = new DocumentProperties ();
newProperties . List = new List < DocumentProperty >();
newProperties . List . Add ( property1 );
newProperties . List . Add ( property2 );
var allProperties = slidesApi . SetDocumentProperties ( "MyPresentation.pptx" , newProperties , null , "MyFolder" );
foreach ( var property in allProperties . List )
{
Debug . WriteLine ( $"{property.Name} : {property.Value} " );
}
}
}
Java
Copy
import com.aspose.slides.ApiException ;
import com.aspose.slides.api.SlidesApi ;
import com.aspose.slides.model.* ;
import java.util.Arrays ;
public class Application {
public static void main ( String [] args ) throws ApiException {
SlidesApi slidesApi = new SlidesApi ( "MyClientId" , "MyClientSecret" );
DocumentProperty property1 = new DocumentProperty ();
property1 . setName ( "ProcessedByOffice" );
property1 . setValue ( "Scotland Team" );
DocumentProperty property2 = new DocumentProperty ();
property2 . setName ( "MyProperty" );
property2 . setValue ( "My Value" );
DocumentProperties newProperties = new DocumentProperties ();
newProperties . setList ( Arrays . asList ( property1 , property2 ));
DocumentProperties allProperties = slidesApi . setDocumentProperties ( "MyPresentation.pptx" , newProperties , null , "MyFolder" , null );
for ( DocumentProperty property : allProperties . getList ()) {
System . out . printf ( "%s: %s%n" , property . getName (), property . getValue ());
}
}
}
PHP
Copy
use Aspose \Slides \Cloud \Sdk \Api \Configuration ;
use Aspose \Slides \Cloud \Sdk \Api \SlidesApi ;
use Aspose \Slides \Cloud \Sdk \Model \DocumentProperty ;
use Aspose \Slides \Cloud \Sdk \Model \DocumentProperties ;
$configuration = new Configuration ();
$configuration -> setAppSid ( "MyClientId" );
$configuration -> setAppKey ( "MyClientSecret" );
$slidesApi = new SlidesApi ( null , $configuration );
$property1 = new DocumentProperty ();
$property1 -> setName ( "ProcessedByOffice" );
$property1 -> setValue ( "Scotland Team" );
$property2 = new DocumentProperty ();
$property2 -> setName ( "MyProperty" );
$property2 -> setValue ( "My Value" );
$newProperties = new DocumentProperties ();
$newProperties -> setList ([ $property1 , $property2 ]);
$allProperties = $slidesApi -> setDocumentProperties ( "MyPresentation.pptx" , $newProperties , null , "MyFolder" );
foreach ( $allProperties -> getList () as $property ) {
echo sprintf ( "%s: %s \n " , $property -> getName (), $property -> getValue ());
}
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 )
property1 = AsposeSlidesCloud :: DocumentProperty . new
property1 . name = "ProcessedByOffice"
property1 . value = "Scotland Team"
property2 = AsposeSlidesCloud :: DocumentProperty . new
property2 . name = "MyProperty"
property2 . value = "My Value"
new_properties = AsposeSlidesCloud :: DocumentProperties . new
new_properties . list = [ property1 , property2 ]
all_properties = slides_api . set_document_properties ( "MyPresentation.pptx" , new_properties , nil , "MyFolder" )
for property in all_properties . list
puts " #{ property . name } : #{ property . value } "
end
Python
Copy
import asposeslidescloud
from asposeslidescloud.apis.slides_api import SlidesApi
from asposeslidescloud.models.document_properties import DocumentProperties
from asposeslidescloud.models.document_property import DocumentProperty
slides_api = SlidesApi ( None , "MyClientId" , "MyClientSecret" )
property1 = DocumentProperty ()
property1 . name = "ProcessedByOffice"
property1 . value = "Scotland Team"
property2 = DocumentProperty ()
property2 . name = "MyProperty"
property2 . value = "My Value"
new_properties = DocumentProperties ()
new_properties . list = [ property1 , property2 ]
all_properties = slides_api . set_document_properties ( "MyPresentation.pptx" , new_properties , None , "MyFolder" )
for property in all_properties . list :
print ( f "{property .name} : {property .value} " )
Node.js
Copy
const cloud = require ( "asposeslidescloud" );
const slidesApi = new cloud . SlidesApi ( "MyClientId" , "MyClientSecret" );
const property1 = new cloud . DocumentProperty ();
property1 . name = "ProcessedByOffice" ;
property1 . value = "Scotland Team" ;
const property2 = new cloud . DocumentProperty ();
property2 . name = "MyProperty" ;
property2 . value = "My Value" ;
const newProperties = new cloud . DocumentProperties ();
newProperties . list = [ property1 , property2 ];
slidesApi . setDocumentProperties ( "MyPresentation.pptx" , newProperties , null , "MyFolder" ). then ( allProperties => {
allProperties . body . list . forEach ( property => {
console . log ( property . name + ": " + property . value );
});
});
C++
Copy
#include "asposeslidescloud/api/SlidesApi.h"
using namespace asposeslidescloud :: api ;
int main ()
{
auto slidesApi = new SlidesApi ( L "MyClientId" , L "MyClientSecret" );
auto property1 = std :: make_shared < DocumentProperty > ();
property1 -> setName ( L "ProcessedByOffice" );
property1 -> setValue ( L "Scotland Team" );
auto property2 = std :: make_shared < DocumentProperty > ();
property2 -> setName ( L "MyProperty" );
property2 -> setValue ( L "My Value" );
auto newProperties = std :: make_shared < DocumentProperties > ();
newProperties -> setList ({ property1 , property2 });
auto allProperties = slidesApi -> setDocumentProperties ( L "MyPresentation.pptx" , newProperties , L "" , L "MyFolder" ). get ();
for ( auto property : allProperties -> getList ()) {
std :: wcout << property -> getName () << L ": " << property -> getValue () << std :: endl ;
}
std :: cin . get ();
return 0 ;
}
Perl
Copy
use AsposeSlidesCloud::Configuration ;
use AsposeSlidesCloud::SlidesApi ;
use AsposeSlidesCloud::Object::DocumentProperty ;
use AsposeSlidesCloud::Object::DocumentProperties ;
my $config = AsposeSlidesCloud::Configuration -> new ();
$config -> { app_sid } = "MyClientId" ;
$config -> { app_key } = "MyClientSecret" ;
my $slides_api = AsposeSlidesCloud::SlidesApi -> new ( config => $config );
my $property1 = AsposeSlidesCloud::Object::DocumentProperty -> new ();
$property1 -> { name } = "ProcessedByOffice" ;
$property1 -> { value } = "Scotland Team" ;
my $property2 = AsposeSlidesCloud::Object::DocumentProperty -> new ();
$property2 -> { name } = "MyProperty" ;
$property2 -> { value } = "My Value" ;
my $new_properties = AsposeSlidesCloud::Object::DocumentProperties -> new ();
$new_properties -> { list } = [ $property1 , $property2 ];
my %parameters = ( name => "MyPresentation.pptx" , properties => $new_properties , folder => "MyFolder" );
my $all_properties = $slides_api -> set_document_properties ( %parameters );
for my $property ( @ { $all_properties -> { list }}) {
print ( "$property->{name}: $property->{value}\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.