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

Public Class AddEmbeddedFonts
    Public Function CreatePDF(ByVal stream As Stream) As Integer
        ' Load a PDF that does not have embedded fonts:
        Using fs = File.OpenRead(Path.Combine("Resources", "PDFs", "CompleteJavaScriptBook-nofonts.pdf"))
            Dim docSrc = New GcPdfDocument()
            docSrc.Load(fs)

            ' Create a new document and draw each page of the original PDF into it:
            Dim doc = New GcPdfDocument()
            ' Not really needed as EmbedSubset is the default for new GcPdfDocument:
            ' doc.FontEmbedMode = FontEmbedMode.EmbedSubset;
            For Each p In docSrc.Pages
                Dim pNew = doc.NewPage()
                pNew.Size = p.Size
                pNew.Graphics.DrawPdfPage(p, p.Bounds)
            Next

            '' Done:
            doc.Save(stream)
            Return doc.Pages.Count
        End Using
    End Function
End Class