StandardPdfFonts.vb
''
'' This code is part of GrapeCity Documents for PDF samples.
'' Copyright (c) GrapeCity, Inc. All rights reserved.
''
Imports System.IO
Imports System.Drawing
Imports GrapeCity.Documents.Pdf
Imports GrapeCity.Documents.Text

'' PDF specification lists 14 standard fonts that should always be available.
'' GcPdf has those fonts built in, and allows to use them directly as this sample demonstrates.
Public Class StandardPdfFonts
    Function CreatePDF(ByVal stream As Stream) As Integer
        Dim doc = New GcPdfDocument()
        Dim g = doc.NewPage().Graphics
        '' Insertion point (GcPdf's default resolution is 72dpi, use 1" margins all around):
        Const margin = 72
        Dim ip = New PointF(margin, margin)
        Dim tf = New TextFormat() With {.FontSize = 12}
        Dim drawText As Action(Of String, Font) =
            Sub(tag_ As String, fnt_ As Font)
                tf.Font = fnt_
                Dim tstr = $"{tag_} ({fnt_.FullFontName}): The quick brown fox jumps over the lazy dog."
                Dim s = g.MeasureString(tstr, tf, doc.PageSize.Width - margin * 2)
                g.DrawString(tstr, tf, New RectangleF(ip, s))
                ip.Y += s.Height * 1.5F
            End Sub
        '' Draw samples of all 14 standard fonts:
        drawText("Helvetica", StandardFonts.Helvetica)
        drawText("HelveticaItalic", StandardFonts.HelveticaItalic)
        drawText("HelveticaBold", StandardFonts.HelveticaBold)
        drawText("HelveticaBoldItalic", StandardFonts.HelveticaBoldItalic)
        drawText("Times", StandardFonts.Times)
        drawText("TimesItalic", StandardFonts.TimesItalic)
        drawText("TimesBold", StandardFonts.TimesBold)
        drawText("TimesBoldItalic", StandardFonts.TimesBoldItalic)
        drawText("Courier", StandardFonts.Courier)
        drawText("CourierItalic", StandardFonts.CourierItalic)
        drawText("CourierBold", StandardFonts.CourierBold)
        drawText("CourierBoldItalic", StandardFonts.CourierBoldItalic)
        drawText("Symbol", StandardFonts.Symbol)
        drawText("ZapfDingbats", StandardFonts.ZapfDingbats)
        ''
        '' Done:
        doc.Save(stream)
        Return doc.Pages.Count
    End Function
End Class