Replace Presentation Fonts Introduction
Aspose.Slides Cloud API allows replacing a font used in a presentation. The feature can be applied to presentations located in the storage or presentations uploaded in the request body. Optionaly the new font can be embedded.
ReplaceFont
API
Type
Description
Resource
/slides/{name}/fonts/{sourceFont}/replace/{targetFont}
POST
Replaces specified font and returns presentation fonts info.
ReplaceFont
Examples
cURL Example
The code examples below show how to replace a font in the presentation in the storage.
SDK Examples
C#
SlidesApi api = new SlidesApi ( "MyClientId" , "MyClientSecret" );
FontsData response = api . ReplaceFont ( "MyPresentation.pptx" , "Calibri" , "Times New Roman" , true );
Console . WriteLine ( "Font Calibri has been replaced with Times New Roman." );
Java
SlidesApi api = new SlidesApi ( "MyClientId" , "MyClientSecret" );
FontsData response = api . replaceFont ( "MyPresentation.pptx" , "Calibri" , "Times New Roman" , true , null , null , null , null );
System . out . println ( "Font Calibri has been replaced with Times New Roman." );
PHP
use Aspose\Slides\Cloud\Sdk\Api\Configuration ;
use Aspose\Slides\Cloud\Sdk\Api\SlidesApi ;
use Aspose\Slides\Cloud\Sdk\Model\FontsData ;
$config = new Configuration ();
$config -> setAppSid ( "MyClientId" );
$config -> setAppKey ( "MyClientSecret" );
$api = new SlidesApi ( null , $config );
$result = $api -> replaceFont ( "MyPresentation.pptx" , "Calibri" , "Times New Roman" , true );
print ( "Font Calibri has been replaced with Times New Roman." );
Ruby
configuration = AsposeSlidesCloud :: Configuration . new
configuration . app_sid = "MyClientId"
configuration . app_key = "MyClientSecret"
api = AsposeSlidesCloud :: SlidesApi . new ( configuration )
response = api . replace_font ( "MyPresentation.pptx" , "Calibri" , "Times New Roman" , true )
print "Font Calibri has been replaced with Times New Roman."
Python
import asposeslidescloud
from asposeslidescloud.configuration import Configuration
from asposeslidescloud.apis.slides_api import SlidesApi
configuration = Configuration ()
configuration . app_sid = 'MyClientId'
configuration . app_key = 'MyClientSecret'
api = SlidesApi ( configuration )
response = api . replace_font ( "MyPresentation.pptx" , "Calibri" , "Times New Roman" , True )
print ( "Font Calibri has been replaced with Times New Roman." )
Node.js
const CloudSdk = require ( "asposeslidescloud" );
const api = new CloudSdk . SlidesApi ( "MyClientId" , "MyClientSecret" );
let result = await api . replaceFont ( "MyPresentation.pptx" , "Calibri" , "Times New Roman" , true );
console . log ( "Font Calibri has been replaced with Times New Roman." );
Go
cfg := asposeslidescloud . NewConfiguration ()
cfg . AppSid = "MyClientId"
cfg . AppKey = "MyClientSecret"
api := asposeslidescloud . NewAPIClient ( cfg )
fileName := "MyPresentation.pptx"
fontName := "Calibri"
targetFontName := "Times New Roman"
var embed bool = true
_ , _ , e := api . SlidesApi . ReplaceFont ( fileName , fontName , targetFontName , & embed , "" , "" , "" , "" )
if e != nil {
fmt . Errorf ( "Error: %v." , e )
return
}
fmt . Printf ( "Font Calibri has been replaced with Times New Roman." )
C++
Perl
use AsposeSlidesCloud::Configuration ;
use AsposeSlidesCloud::SlidesApi ;
use AsposeSlidesCloud::Object::SlideComment ;
my $config = AsposeSlidesCloud::Configuration -> new ();
$config -> { app_sid } = "MyClientId" ;
$config -> { app_key } = "MyClientSecret" ;
my $api = AsposeSlidesCloud::SlidesApi -> new ( config => $config );
#Code example will be added soon.
Swift
ReplaceFontOnline
API
Type
Description
Resource
/slides/fonts/fonts/{sourceFont}/replace/{targetFont}
POST
Replaces specified font and returns presentation.
ReplaceFontOnline
Examples
cURL Example
The code examples below show how to replace a font in the presentation in the request body.
SDK Examples
C#
SlidesApi api = new SlidesApi ( "MyClientId" , "MyClientSecret" );
Stream file = File . OpenRead ( "MyPresentation.pptx" );
Stream response = api . ReplaceFontOnline ( file , "Calibri" , "Times New Roman" , true );
Console . WriteLine ( "Font Calibri has been replaced with Times New Roman." );
Java
SlidesApi api = new SlidesApi ( "MyClientId" , "MyClientSecret" );
byte [] file = Files . readAllBytes ( Paths . get ( "MyPresentation.pptx" ));
File response = api . replaceFontOnline ( file , "Calibri" , "Times New Roman" , true , null , null );
System . out . println ( "Font Calibri has been replaced with Times New Roman." );
PHP
use Aspose\Slides\Cloud\Sdk\Api\Configuration ;
use Aspose\Slides\Cloud\Sdk\Api\SlidesApi ;
use Aspose\Slides\Cloud\Sdk\Model\FontsData ;
$config = new Configuration ();
$config -> setAppSid ( "MyClientId" );
$config -> setAppKey ( "MyClientSecret" );
$api = new SlidesApi ( null , $config );
$file = fopen ( "MyPresentation.pptx" , 'r' );
$result = $api -> replaceFontOnline ( $file , "Calibri" , "Times New Roman" , true );
print ( "Font Calibri has been replaced with Times New Roman." );
Ruby
configuration = AsposeSlidesCloud :: Configuration . new
configuration . app_sid = "MyClientId"
configuration . app_key = "MyClientSecret"
api = AsposeSlidesCloud :: SlidesApi . new ( configuration )
source = File . binread ( "MyPresentation.pptx" )
response = api . replace_font_online ( source , "Calibri" , "Times New Roman" , true )
print "Font Calibri has been replaced with Times New Roman."
Python
import asposeslidescloud
from asposeslidescloud.configuration import Configuration
from asposeslidescloud.apis.slides_api import SlidesApi
configuration = Configuration ()
configuration . app_sid = 'MyClientId'
configuration . app_key = 'MyClientSecret'
api = SlidesApi ( configuration )
with open ( "MyPresentation.pptx" , 'rb' ) as f :
source = f . read ()
response = api . replace_font_online ( source , "Calibri" , "Times New Roman" , True )
print ( "Font Calibri has been replaced with Times New Roman." )
Node.js
const CloudSdk = require ( "asposeslidescloud" );
const fs = require ( "fs" );
const api = new CloudSdk . SlidesApi ( "MyClientId" , "MyClientSecret" );
const stream = fs . createReadStream ( "MyPresentation.pptx" );
let result = await api . replaceFontOnline ( stream , "Calibri" , "Times New Roman" , true );
console . log ( "Font Calibri has been replaced with Times New Roman." );
Go
cfg := asposeslidescloud . NewConfiguration ()
cfg . AppSid = "MyClientId"
cfg . AppKey = "MyClientSecret"
api := asposeslidescloud . NewAPIClient ( cfg )
fontName := "Calibri"
targetFontName := "Times New Roman"
var embed bool = true
document , e := ioutil . ReadFile ( "MyPresentation.pptx" )
_ , _ , e = api . SlidesApi . ReplaceFontOnline ( document , fontName , targetFontName , & embed , "" , "" )
if e != nil {
fmt . Printf ( "Error: %v." , e )
return
}
fmt . Printf ( "Font Calibri has been replaced with Times New Roman." )
C++
Perl
use AsposeSlidesCloud::Configuration ;
use AsposeSlidesCloud::SlidesApi ;
use AsposeSlidesCloud::Object::SlideComment ;
my $config = AsposeSlidesCloud::Configuration -> new ();
$config -> { app_sid } = "MyClientId" ;
$config -> { app_key } = "MyClientSecret" ;
my $api = AsposeSlidesCloud::SlidesApi -> new ( config => $config );
#Code example will be added soon.
Swift
SDK Source
The Aspose for Cloud SDKs can be downloaded from the following page: Available SDKs