Embed File
Embeds a file in a PDF document.
Code
using DRIT.Pdf;
using var doc = new PdfDocument();
var page = doc.Pages.Add(PdfPageSize.A4);
// Embed a file
var embeddedFile = doc.EmbeddedFiles.Add("data.json", "application/json");
using var stream = embeddedFile.OpenWrite();
var data = System.Text.Encoding.UTF8.GetBytes("{\"name\": \"test\"}");
stream.Write(data, 0, data.Length);
// The file is now embedded and will be saved with the document
doc.Save("embedded.pdf");