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

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

Output

embedded.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