Back to Devexpress

PdfExportOptions.Attachments Property

officefileapi-devexpress-dot-docs-dot-presentation-dot-export-dot-pdfexportoptions-2f6b9240.md

latest2.9 KB
Original Source

PdfExportOptions.Attachments Property

Obtains a list of PDF file attachments.

Namespace : DevExpress.Docs.Presentation.Export

Assembly : DevExpress.Docs.Presentation.v25.2.dll

NuGet Package : DevExpress.Docs.Presentation

Declaration

csharp
public ICollection<Attachment> Attachments { get; }
vb
Public ReadOnly Property Attachments As ICollection(Of Attachment)

Property Value

TypeDescription
ICollection<Attachment>

A list of attached files.

|

Example

The following code snippet attaches a PDF file to the exported presentation:

csharp
using DevExpress.Docs.Pdf;
using DevExpress.Docs.Presentation;
using DevExpress.Docs.Presentation.Export;
//...
using (var presentation = new Presentation(File.ReadAllBytes(@"C:\Documents\Presentation.pptx")))
{
    var attachment = new Attachment();
    attachment.Data = File.ReadAllBytes(@"C:\Documents\test.pdf");
    attachment.Relationship = AttachmentRelationship.Supplement;
    attachment.FileName = "attachment.pdf";
    attachment.CreationDate = DateTime.Now;
    attachment.Type = "application/pdf";

    PdfExportOptions options = new PdfExportOptions();
    options.Attachments.Add(attachment);

    presentation.ExportToPdf(new FileStream("C:\\Documents\\Presentation.pdf", FileMode.Create, FileAccess.ReadWrite), options);
}
vb
Imports DevExpress.Docs.Pdf
Imports DevExpress.Docs.Presentation
Imports DevExpress.Docs.Presentation.Export
'...
Using presentation = New Presentation(File.ReadAllBytes("C:\Documents\Presentation.pptx"))
    Dim attachment = New Attachment()
    attachment.Data = File.ReadAllBytes("C:\Documents\test.pdf")
    attachment.Relationship = AttachmentRelationship.Supplement
    attachment.FileName = "attachment.pdf"
    attachment.CreationDate = Date.Now
    attachment.Type = "application/pdf"

    Dim options As New PdfExportOptions()
    options.Attachments.Add(attachment)

    presentation.ExportToPdf(new FileStream("C:\Documents\Presentation.pdf", FileMode.Create, FileAccess.ReadWrite), options)
End Using

See Also

PdfExportOptions Class

PdfExportOptions Members

DevExpress.Docs.Presentation.Export Namespace