ServerSheetControl.GetFontFileAsync Method
- Namespace
TXTextControl.TXSheetControl. Server
- Package
TXTextControl.asTXSheetControl. Server TXTextControl.from the private NuGet feed or the supplied NuGet folderTXSheetControl. Server. dll
Reads a catalogued face for HTTP hosting, using the same bytes as PDF export.
Syntax
public Task<byte[]> GetFontFileAsync(string fileName, string hash, CancellationToken cancellationToken = default)
Parameters
| Parameter | Type | Optional | Description |
|---|---|---|---|
fileName | string | No | Unescaped filename from the catalog face URL. |
hash | string | No | SHA-256 content version from the URL. Stale versions are rejected. |
cancellationToken | CancellationToken | Yes | Cancels the pending operation. |
Return Value
Task<byte[]>. Owned font bytes. Server filesystem paths remain private.
Examples
Create and format a complete invoice before using this processing API. Return document bytes, operation metadata or notifications to the application; dispose owned controls after processing.
using TXTextControl.TXSheetControl.Server;
async Task<byte[]> CreateInvoiceGetFontFileAsyncAsync(ServerSheetControl control)
{
var catalog = await control.GetFontCatalogAsync();
var face = catalog.Families.First().Faces.First();
var url = new Uri("https://fonts.example/" + face.Url);
var fileName = Uri.UnescapeDataString(Path.GetFileName(url.AbsolutePath));
var hash = url.Query.TrimStart('?').Split('&').Select(pair => pair.Split('=', 2)).Single(pair => pair[0] == "v")[1];
return await control.GetFontFileAsync(fileName, hash);
}
Remarks
Use the member with an instance or settings object from the documented package. Await task-returning operations. Document-bound handles must be resolved again after loading or deleting their owner.