Attachment Class
A file attached to a PDF document.
Namespace: DevExpress.Docs.Pdf
Assembly: DevExpress.Docs.Core.v26.1.dll
NuGet Package: DevExpress.Docs.Core
Declaration
Examples
How to: Attach a File to a Presentation Exported to PDF
The following code snippet attaches a PDF file to the exported presentation:
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 = AssociatedFileRelationship.Supplement;
attachment.FileName = "attachment.pdf";
attachment.CreationDate = DateTime.Now;
attachment.MimeType = "application/pdf";
PdfExportOptions options = new PdfExportOptions();
options.Attachments.Add(attachment);
presentation.ExportToPdf(new FileStream("C:\\Documents\\Presentation.pdf", FileMode.Create, FileAccess.ReadWrite), options);
}
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);
}
}
Inheritance
Object
Attachment
See Also