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

'' Shows how to attach files to a PDF document.
'' See also the FileAttachments sample that demonstrates file attachment annotations,
'' which are attached to a specific location on a page.
Public Class DocAttachments
    Function CreatePDF(ByVal stream As Stream) As Integer
        Dim doc = New GcPdfDocument()
        Dim page = doc.NewPage()
        Dim files As String() =
        Dim sb = New StringBuilder()
        For Each fn In files
            "Several images from the sample's Resources/Images folder are attached to this document:" + vbLf + vbLf +
            sb.ToString(), page)
        For Each fn In files
            Dim file = Path.Combine("Resources", "Images", fn)
            Dim fspec = FileSpecification.FromEmbeddedFile(EmbeddedFileStream.FromFile(doc, file))
            doc.EmbeddedFiles.Add(file, fspec)
        '' Done:
        Return doc.Pages.Count
    End Function
End Class