'''' This code is part of Document Solutions for PDF .NET demos.'' Copyright (c) MESCIUS inc. All rights reserved.''ImportsSystem.IOImportsSystem.DrawingImportsGrapeCity.Documents.PdfImportsGrapeCity.Documents.Pdf.Annotations '' This sample demonstrates how to create file attachment annotations on a page.'' See also the DocAttachments sample that demonstrates document level file attachments.PublicClassFileAttachmentsFunctionCreatePDF(ByVal stream AsStream) AsIntegerDim doc = NewGcPdfDocument()Dim page = doc.NewPage()Dim g = page.Graphics Dim rc = Util.AddNote("Some files from the sample's Resources/Images folder are attached to this page." + vbLf +"Some viewers may not show attachments, so we draw rectangles to indicate their (usually clickable) locations.", page)Dim ip = NewPointF(rc.X, rc.Bottom + 9)Dim attSize = NewSizeF(36, 12)Dim gap = 8Dim files AsString() = {"tudor.jpg","sea.jpg","puffins.jpg","lavender.jpg","skye.jpg","fiord.jpg","newfoundland.jpg" }ForEach fn In filesDim File = Path.Combine("Resources", "Images", fn)Dim faa = NewFileAttachmentAnnotation() With { .Color = Color.FromArgb(&HFFC540A5), .UserName = "Jaime Smith", .Rect = NewRectangleF(ip.X, ip.Y, attSize.Width, attSize.Height), .Contents = "Attached file: " + File, .Icon = FileAttachmentAnnotationIcon.Paperclip, .File = FileSpecification.FromEmbeddedFile(EmbeddedFileStream.FromFile(doc, File)) } page.Annotations.Add(faa) g.FillRectangle(faa.Rect, Color.FromArgb(&HFF40C5A3)) g.DrawRectangle(faa.Rect, Color.FromArgb(&HFF6040C5)) ip.Y += attSize.Height + gapNext'''' Done: doc.Save(stream)Return doc.Pages.CountEndFunctionEndClass