//// This code is part of Document Solutions for PDF .NET demos.// Copyright (c) MESCIUS inc. All rights reserved.//usingSystem.IO;usingSystem.Drawing;usingGrapeCity.Documents.Pdf;usingGrapeCity.Documents.Pdf.Annotations; namespaceDsPdfWeb.Demos.Basics{// This sample demonstrates how to create file attachment annotations on a page. // See also the DocAttachments sample that demonstrates document level file attachments.publicclassFileAttachments {publicintCreatePDF(Stream stream) {var doc = newGcPdfDocument();var page = doc.NewPage();var g = page.Graphics; var rc = Common.Util.AddNote("Some files from the sample's Resources/Images folder are attached to this page.\n" +"Some viewers may not show attachments, so we draw rectangles to indicate their (usually clickable) locations.", page);var ip = newPointF(rc.X, rc.Bottom + 9);var attSize = newSizeF(36, 12);var gap = 8;var files = newstring[] {"tudor.jpg","sea.jpg","puffins.jpg","lavender.jpg","skye.jpg","fiord.jpg","newfoundland.jpg" };foreach (string fn in files) {var file = Path.Combine("Resources", "Images", fn);var faa = newFileAttachmentAnnotation() {Color = Color.FromArgb(unchecked((int)0xFFc540a5)),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(unchecked((int)0xFF40c5a3))); g.DrawRectangle(faa.Rect, Color.FromArgb(unchecked((int)0xFF6040c5))); ip.Y += attSize.Height + gap; }// Done: doc.Save(stream);return doc.Pages.Count; } }}