• DR-IT Software
  • Products
  • Documentation
  • Product page
  • Examples
  • API reference
  • Support

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");

Output

attachment.pdf

  • Improve this Doc
Back to top

DR-IT Software documentation

DR-IT Software · Products · Documentation index · Product page · Downloads · Support · Licensing

Generated by DocFX