How To Use Standard Built-in Fonts For Writing Text In PDF documents

This example demonstrates how to use built-in "standard" fonts for text in PDF. The enum PDFStandardFont specifies the standard PDF font families.

C# :

using PDFMosaic;
using System;
using System.Drawing;

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

      PDFBrush brush = new PDFSolidBrush();

      int dy = 10;
      foreach(PDFStandardFont standardFont in Enum.GetValues(typeof(PDFStandardFont)))
      {
          PDFFont currentFont = new PDFFont(standardFont, 12);
          canvas.DrawString(standardFont.ToString(), currentFont, brush, 10, dy);
          dy += 30;
      }

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

VB.NET :

Imports PDFMosaic
Imports System
Imports System.Drawing

Module StandardFonts
  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 dy As Integer = 10
    For Each standardFont As PDFStandardFont In [Enum].GetValues(GetType(PDFStandardFont))
    Dim currentFont As New PDFFont(standardFont, 12)
    canvas.DrawString(standardFont.ToString(), currentFont, brush, 10, dy)
    dy += 30
    next

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