File Attachment
Adds a file attachment annotation to a PDF page.
Code
using DRIT.Pdf;
using var doc = new PdfDocument();
var page = doc.Pages.Add(PdfPageSize.A4);
// Add an embedded file
var embeddedFile = doc.EmbeddedFiles.Add("readme.txt", "text/plain");
embeddedFile.OpenWrite().Write(System.Text.Encoding.UTF8.GetBytes("Hello from embedded file!"));
// Add a file attachment annotation
var attachment = page.Annotations.AddFileAttachment(new PdfPoint(100, 700), embeddedFile);
attachment.Description = "Readme file";
doc.Save("attachment.pdf");