Set Embedded Fonts Introduction
Aspose.Slides Cloud API allows embedding multiple fonts in one request. You can specify font names in the query string, or (and) provide the font files in the request body. The second option is good for custom fonts that are not available on the server. The feature can be applied to presentations located in the storage or presentations uploaded in the request body along with the font file(s).
SetEmbeddedFonts
API
Type
Description
Resource
/slides/{name}/fonts/embedded
POST
Embeds fonts and returns presentation fonts information.
SetEmbeddedFonts
Examples
cURL Example
The code examples below show how to embed fonts in a presentation located in the storage.
SDK Examples
C#
SlidesApi api = new SlidesApi ( "MyClientId" , "MyClientSecret" );
Stream fontFile1 = File . OpenRead ( "calibri.ttf" );
Stream fontFile2 = File . OpenRead ( "arial.ttf" );
List < FileInfo > fontFiles = new List < FileInfo >
{
new FileInfo { Name = "calibri.ttf" , Content = fontFile1 },
new FileInfo { Name = "arial.ttf" , Content = fontFile2 }
};
FontsData response = api . SetEmbeddedFonts ( "MyPresentation.pptx" , fontFiles , null , false );
Console . WriteLine ( "Number of used fonts: " + response . List . Count );
Java
SlidesApi api = new SlidesApi ( "MyClientId" , "MyClientSecret" );
FileInfo file1 = new FileInfo ();
file1 . setName ( "calibri.ttf" );
file1 . setData ( Files . readAllBytes ( Paths . get ( "calibri.ttf" )));
FileInfo file2 = new FileInfo ();
file2 . setName ( "arial.ttf" );
file2 . setData ( Files . readAllBytes ( Paths . get ( "arial.ttf" )));
List < FileInfo > fontFiles = new ArrayList < FileInfo >();
fontFiles . add ( file1 );
fontFiles . add ( file2 );
FontsData response = api . setEmbeddedFonts ( "MyPresentation.pptx" , fontfiles , null , false , null , null , null );
System . out . println ( "Number of used fonts: " + response . getList (). size ());
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 );
$file1 = fopen ( "calibri.ttf" , 'r' );
$file2 = fopen ( "arial.ttf" , 'r' );
$files = [ $file1 , $file2 ];
$result = $api -> setEmbeddedFonts ( "MyPresentation.pptx" , $files , null , false );
print ( "Number of used fonts: " . count ( $result -> getList ()));
Ruby
configuration = AsposeSlidesCloud :: Configuration . new
configuration . app_sid = "MyClientId"
configuration . app_key = "MyClientSecret"
api = AsposeSlidesCloud :: SlidesApi . new ( configuration )
source1 = File . binread ( "calibri.ttf" )
source2 = File . binread ( "arial.ttf" )
response = api . set_embedded_fonts ( "MyPresentation.pptx" , [ source1 , source2 ] , nil , false )
print "Number of used fonts: " + response . list . length
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 ( "calibri.ttf" , 'rb' ) as f :
source1 = f . read ()
with open ( "arial.ttf" , 'rb' ) as f :
source2 = f . read ()
response = api . set_embedded_fonts ( "MyPresentation.pptx" , [ source1 , source2 ], None , False )
print ( "Number of used fonts: " + len ( response . list ) + " has been embedded." )
Node.js
const CloudSdk = require ( "asposeslidescloud" );
const fs = require ( "fs" );
const api = new CloudSdk . SlidesApi ( "MyClientId" , "MyClientSecret" );
const file1 = fs . createReadStream ( "calibri.ttf" );
const file2 = fs . createReadStream ( "arial.ttf" );
let result = await api . setEmbeddedFonts ( "MyPresentation.pptx" , [ file1 , file2 ], null , false );
console . log ( "Number of used fonts: " + result . body . list . length );
Go
cfg := asposeslidescloud . NewConfiguration ()
cfg . AppSid = "MyClientId"
cfg . AppKey = "MyClientSecret"
api := asposeslidescloud . NewAPIClient ( cfg )
font1 , e := ioutil . ReadFile ( "calibri.ttf" )
if e != nil {
fmt . Printf ( "Error: %v." , e )
return
}
font2 , e := ioutil . ReadFile ( "arial.ttf" )
if e != nil {
fmt . Printf ( "Error: %v." , e )
return
}
var onlyUsed bool = false
response , _ , e := api . SlidesApi . SetEmbeddedFonts ( "MyPresentation.pptx" , [][] byte { font1 , font2 }, nil , & onlyUsed , "" , "" , "" )
if e != nil {
fmt . Printf ( "Error: %v." , e )
return
}
fmt . Printf ( "Number of used fonts: " + len ( response . GetList ()))
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
SetEmbeddedFontsOnline
API
Type
Description
Resource
/slides/fonts/embedded
POST
Embeds fonts and returns the presentation.
SetEmbeddedFontsOnline
Examples
cURL Example
The code examples below show how to embed fonts in a presentation located in the request body.
SDK Examples
C#
SlidesApi api = new SlidesApi ( "MyClientId" , "MyClientSecret" );
Stream file = File . OpenRead ( "MyPresentation.pptx" );
List < string > fontsToEmbed = new List < string > { "Calibri" , "Arial" };
Stream response = api . SetEmbeddedFontsOnline ( file , null , fontsToEmbed , false );
Console . WriteLine ( "Fonts have been embedded." );
Java
SlidesApi api = new SlidesApi ( "MyClientId" , "MyClientSecret" );
ArrayList fonts = new ArrayList ( Arrays . asList ( "Calibri" , "Arial" ));
File response = api . setEmbeddedFontsOnline ( file , null , fonts , false , null );
System . out . println ( "Fonts have been embedded." );
PHP
use Aspose\Slides\Cloud\Sdk\Api\Configuration ;
use Aspose\Slides\Cloud\Sdk\Api\SlidesApi ;
$config = new Configuration ();
$config -> setAppSid ( "MyClientId" );
$config -> setAppKey ( "MyClientSecret" );
$api = new SlidesApi ( null , $config );
$file = fopen ( "MyPresentataion.pptx" , 'r' );
$result = $api -> setEmbeddedFontsOnline ( $file , null , [ "Calibri" , "Arial" ], false );
print ( "Fonts have been embedded." );
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 . set_embedded_fonts_online ( source , nil , [ "Calibri" , "Arial" ] , false )
print "Fonts have been embedded."
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 . set_embedded_fonts_online ( source , None , [ "Calibri" , "Arial" ], False )
print ( "Fonts have been embedded." )
Node.js
const CloudSdk = require ( "asposeslidescloud" );
const fs = require ( "fs" );
const api = new CloudSdk . SlidesApi ( "MyClientId" , "MyClientSecret" );
const stream = fs . createReadStream ( "MyPresentation.pptx" );
let reponse = await api . setEmbeddedFontsOnline ( stream , null , [ "Calibri" , "Arial" ], false );
console . log ( "Fonts have been embedded." );
Go
cfg := asposeslidescloud . NewConfiguration ()
cfg . AppSid = "MyClientId"
cfg . AppKey = "MyClientSecret"
api := asposeslidescloud . NewAPIClient ( cfg )
document , e := ioutil . ReadFile ( "MyPresentation.pptx" )
if e != nil {
fmt . Printf ( "Error: %v." , e )
return
}
var onlyUsed bool = false
_ , _ , e = api . SlidesApi . SetEmbeddedFontsOnline ( document , nil , [] string { "Calibri" , "Arial" }, & onlyUsed , "" )
if e != nil {
fmt . Printf ( "Error: %v." , e )
return
}
fmt . Printf ( "Fonts have been embedded." )
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