How To Load OpenType Font using PDF Mosaic .NET Library

The example demonstares how to write text using OpenType Font with help of PDF Mosaic .NET Library.

OpenType Font

C# :

using PDFMosaic;
using System.Drawing;

namespace OpenTypeFont
{
  class Fonts
  {
    static void Main()
    {
      PDFDocument document = new PDFDocument();
      document.Pages.Add(new PDFPage(PDFPaperFormat.A4));
      PDFCanvas canvas = document.Pages[0].Canvas;

      PDFBrush brush = new PDFSolidBrush();

      PDFFont fontFromFile = PDFFont.FromFile("c:\\fummel.otf", 12);
      canvas.DrawString("opentype Font from file.", fontFromFile, brush, 10, 120);

      document.Save("OpenTypeFont.pdf", true);
    }
  }
}

VB.NET :

Imports PDFMosaic
Imports System.Drawing

Module OpenTypeFont
  Sub Main()    
    Dim document As New PDFDocument()
    document.Pages.Add(New PDFPage(PDFPaperFormat.A4))
    Dim canvas = document.Pages(0).Canvas

    Dim brush As New PDFSolidBrush()

    Dim fontFromFile = PDFFont.FromFile("c:\\fummel.otf", 12)
    canvas.DrawString("Font from file.", fontFromFile, brush, 10, 120)

    document.Save("OpenTypeFont.pdf", True)
  End Sub
End Module