Skip to main content
All docs
V26.1
  • PdfDocument.Attachments Property

    Obtains a collection of file attachments included in a PDF document.

    Namespace: DevExpress.Docs.Pdf

    Assembly: DevExpress.Docs.Pdf.v26.1.dll

    Declaration

    public AttachmentCollection Attachments { get; }

    Property Value

    Type Description
    AttachmentCollection

    The attachment collection.

    Example

    How to: Attach a File to a PDF File

    The following code snippet attaches a file to a PDF document.

    using DevExpress.Docs.Pdf;
    
    using (PdfDocument pdfDocument =
        new PdfDocument(File.OpenRead(@"document_001.pdf")))
    
    {
        var attachment = new Attachment();
        attachment.Data = File.ReadAllBytes(@"C:\Documents\test.pdf");
        attachment.Relationship = AssociatedFileRelationship.Supplement;
        attachment.FileName = "attachment.pdf";
        attachment.CreationDate = DateTime.Now;
        attachment.MimeType = "application/pdf";
    
        pdfDocument.Attachments.Add(attachment);
    
        using (FileStream outputStream = File.Create(@"document_001_with_attachment.pdf"))
        {
            pdfDocument.Save(outputStream);
        }
    }
    
    See Also