Type1FontsDemo.vb
''
'' This code is part of Document Solutions for PDF .NET demos.
'' Copyright (c) MESCIUS inc. All rights reserved.
''
Imports System.IO
Imports System.Drawing
Imports GrapeCity.Documents.Pdf
Imports GrapeCity.Documents.Text

Public Class Type1FontsDemo
    Public Function CreatePDF(ByVal stream As Stream) As Integer
        Dim doc = New GcPdfDocument()
        ' We load a PDF that uses PDF Type 1 fonts, add some text to it,
        ' and save it to PDF and images (JPEG and TIFF) as in all other samples.
        ' The original text in the loaded PDF is rendered using Adobe Type 1 fonts,
        ' so if using DsPdf v4.0 or earlier, the generated images would contain
        ' garbled text. Starting with v4.1, Type 1 fonts are rendered correctly.
        Using fs = File.OpenRead(Path.Combine("Resources", "PDFs", "Type1FontSample.pdf"))
            doc.Load(fs)
            '' Add note to the (only) page in the doc:
            Dim page = doc.Pages.Last
            Util.AddNote(
                "This sample demonstrates rendering Adobe Type 1 fonts when a PDF is saved as image by DsPdf. " &
                "This is supported starting with DsPdf v4.1. To see the result, open the generated PDF " &
                "saved as image (e.g. TIFF). Using the same code with an earlier version of DsPdf produces " &
                "garbled text in the saved image.",
                page,
                New RectangleF(12, 12, 72 * 5, 0))
            '' Done:
            doc.Save(stream)
            Return doc.Pages.Count
        End Using
    End Function
End Class