'''' This code is part of Document Solutions for PDF .NET demos.'' Copyright (c) MESCIUS inc. All rights reserved.''ImportsSystem.IOImportsSystem.TextImportsGrapeCity.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.PublicClassDocAttachmentsFunctionCreatePDF(ByVal stream AsStream) AsIntegerDim doc = NewGcPdfDocument()Dim page = doc.NewPage()Dim files As (String, String)() = { ("Images", "tudor.jpg"), ("Images", "sea.jpg"), ("Images", "puffins.jpg"), ("Images", "lavender.jpg"), ("Images", "skye.jpg"), ("Images", "fiord.jpg"), ("Images", "newfoundland.jpg"), ("PDFs", "HelloWorld.pdf"), ("PDFs", "FormFields.pdf") }Dim sb = NewStringBuilder()ForEach f In files sb.AppendLine(f.Item2)NextUtil.AddNote("Several images and PDFs are attached to this document:" + vbLf + vbLf + sb.ToString(), page)ForEach f In filesDim file = Path.Combine("Resources", f.Item1, f.Item2)Dim fspec = FileSpecification.FromEmbeddedFile(EmbeddedFileStream.FromFile(doc, file)) doc.EmbeddedFiles.Add(file, fspec)Next'''' Done: doc.Save(stream)Return doc.Pages.CountEndFunctionEndClass