
字体是使文档更具可呈现性的关键元素。在字体的帮助下,信息以更便于阅读和管理的格式呈现。Aspose.Slides Cloud API 支持在创建或编辑现有 PowerPoint 演示文稿时指定自定义字体的功能。您还可以为 OpenOffice 文档设置字体。同时,您可以在将 PPTX 导出到其他支持的格式时指定 DefaultRegularFont。
除了在 PowerPoint 操作过程中使用字体之外,Cloud API 现在还支持指定默认常规字体的能力。您可以在将 PowerPoint 导出为其他支持的格式时设置字体。该 API 当前支持对 PPTX、PPT、PPSX,、PPTM 和其他流行 PowerPoint 格式的操作。您可以将其保存为类似格式以及其他格式,如 PDF、SVG、HTML、XPS、JPEG、PNG、TTF。此外,在最近的版本中,实施了一项新功能,可以指定默认常规字体。它允许您指定默认字体以替代未提供的自定义字体。
在我们进一步进行之前,我们建议访问以下链接以获取有关 如何使用客户端ID和客户端密钥获取JWT令牌 的信息。 请注意,当尝试通过命令提示符访问REST API时,需要JWT令牌。
此外,为了通过编程语言使用 Cloud API,您需要尝试安装专为某些编程语言创建的 SDK。有关更多信息,请访问 如何安装 Aspose.Cloud SDKs。
cURL
curl -X POST "https://api.aspose.cloud/v3.0/slides/NotesPresentation-1.pptx/Pdf" \
-H "accept: multipart/form-data" \
-H "authorization: Bearer <JWT Token>" \
-H "Content-Type: application/json" \
-d "{ \"DefaultRegularFont\": \"Calibri\", \"Format\": \"ExportFormat.Pdf\"}"
请求 URL
https://api.aspose.cloud/v3.0/slides/NotesPresentation-1.pptx/Pd
C#.NET
string MyAppKey = "xxxxxxxx"; // Get AppKey and AppSID from https://dashboard.aspose.cloud/
string MyAppSid = "xxxxxxxx"; // Get AppKey and AppSID from https://dashboard.aspose.cloud/
SlidesApi api = new SlidesApi(MyAppSid, MyAppKey);
PostSlidesSaveAsRequest request = new PostSlidesSaveAsRequest
{
Name = "myPresentaion.pptx",
Folder = "myFolder",
Format = ExportFormat.Pdf,
Options = new PdfExportOptions { DefaultRegularFont = "Calibri" }
};
Stream response = api.PostSlidesSaveAs(request);
response.CopyTo(File.Create("myPresentation.pdf"));
自定义字体在转换期间
除了在PPTX导出期间设置 DefaultRegularFont 外,云API还支持在导出到其他支持的格式时设置自定义字体。以下代码片段展示了如何在导出为PDF格式时设置Calibri字体。
C#.NET
string MyAppKey = "xxxxxxxx"; // Get AppKey and AppSID from https://dashboard.aspose.cloud/
string MyAppSid = "xxxxxxxx"; // Get AppKey and AppSID from https://dashboard.aspose.cloud/
SlidesApi api = new SlidesApi(MyAppSid, MyAppKey);
try
{
FileStream file = File.Open("Resources\\test-unprotected.ppt", FileMode.Open);
var request = new PostSlidesConvertRequest(ExportFormat.Pdf, file, null, "customfonts/Pacifico.ttf");
var response = slidesApi.PostSlidesConvert(request);
Console.WriteLine("Response: " + response.ToString());
}
catch (Exception e)
{
Console.WriteLine("Exception while calling Api: " + e.ToString());
}