Attachments

This module uses the New DevExpress PDF Document API (PdfDocument) to attach files to a PDF document. You can process the predefined sample file or supply your own document. To do the latter, select Upload a File in the file selection drop-down menu.

Click Add Attachment and Save to attach the predefined file to the PDF and download the result.

Select a Document
Sample_Alternative.pdf
Default image



using DevExpress.Docs.Pdf;

Stream AttachFile(Stream documentStream, string fileName, string fileDescription, string fileMimeType,
    byte[] fileData) {
    using var doc = new PdfDocument(documentStream);
    var attachment = new Attachment() {
        CreationDate = DateTime.UtcNow,
        FileName = fileName,
        Data = fileData,
        MimeType = fileMimeType,
        Description = fileDescription,
        ModificationDate = DateTime.UtcNow,
        Relationship = AssociatedFileRelationship.Supplement
    };
    doc.Attachments.Add(attachment);
    var outputStream = new MemoryStream();
    doc.Save(outputStream);
    return outputStream;
}