/* ----------------------------------------------------------------- */ /// /// Set /// /// <summary> /// Sets attachments to the specified writer. /// </summary> /// /// <param name="src">PdfCopy object.</param> /// <param name="data">Collection of attachments.</param> /// /* ----------------------------------------------------------------- */ public static void Set(this PdfCopy src, IEnumerable <Attachment> data) { var done = new List <Attachment>(); foreach (var item in data) { var dup = done.Any(e => e.Name.ToLower() == item.Name.ToLower() && e.Length == item.Length && e.Checksum.SequenceEqual(item.Checksum) ); if (dup) { continue; } var fs = item is EmbeddedAttachment? PdfFileSpecification.FileEmbedded(src, null, item.Name, item.Data) : PdfFileSpecification.FileEmbedded(src, item.Source, item.Name, null); fs.SetUnicodeFileName(item.Name, true); src.AddFileAttachment(fs); done.Add(item); } }