TX Sheet Control

ServerSheetControl.GetFontFileAsync Method

Method
Namespace
TXTextControl.TXSheetControl.Server
Package
TXTextControl.TXSheetControl.Server as TXTextControl.TXSheetControl.Server.dll from the private NuGet feed or the supplied NuGet folder

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

ParameterTypeOptionalDescription
fileNamestringNoUnescaped filename from the catalog face URL.
hashstringNoSHA-256 content version from the URL. Stale versions are rejected.
cancellationTokenCancellationTokenYesCancels 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.

See Also