PdfDocumentProcessor.AttachFile(PdfFileAttachment) Method
Attaches a file to the PDF document.
Namespace: DevExpress.Pdf
Assembly: DevExpress.Docs.v24.2.dll
NuGet Package: DevExpress.Document.Processor
#Declaration
public void AttachFile(
PdfFileAttachment attachment
)
#Parameters
Name | Type | Description |
---|---|---|
attachment | Pdf |
A Pdf |
#Remarks
Use this method to include an attachment to the PDF document using the necessary settings such as attachment data (PdfFileAttachment.Data), a file name (PdfFileAttachment.FileName), creation date (PdfFileAttachment.CreationDate), modification date (PdfFileAttachment.ModificationDate) and other settings.
#Example
using DevExpress.Pdf;
using System;
using System.IO;
using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
// Load a document.
processor.LoadDocument("..\\..\\Document.pdf");
// Attach a file to the PDF document.
processor.AttachFile(new PdfFileAttachment() {
CreationDate = DateTime.Now,
Description = "This is my attach file.",
FileName = "MyAttach.txt",
Data = File.ReadAllBytes("..\\..\\FileToAttach.txt")
});
// The attached document.
processor.SaveDocument("..\\..\\Result.pdf");
}
#Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the AttachFile(PdfFileAttachment) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.