StreamFontSourceOpenFontDataStream Method |
Namespace: Aspose.Words.Fonts
public void StreamFontSourceFileRendering() { FontSettings fontSettings = new FontSettings(); fontSettings.SetFontsSources(new FontSourceBase[] { new StreamFontSourceFile() }); DocumentBuilder builder = new DocumentBuilder(); builder.Document.FontSettings = fontSettings; builder.Font.Name = "Kreon-Regular"; builder.Writeln("Test aspose text when saving to PDF."); builder.Document.Save(ArtifactsDir + "Font.StreamFontSourceFileRendering.pdf"); } /// <summary> /// Load the font data only when it is required and not to store it in the memory for the "FontSettings" lifetime. /// </summary> private class StreamFontSourceFile : StreamFontSource { public override Stream OpenFontDataStream() { return File.OpenRead(FontsDir + "Kreon-Regular.ttf"); } }