The requested page is not available for the requested platform. You are viewing the content for .NET Framework 4.5.2+ platform.
.NET Framework 4.5.2+
.NET Framework 4.5.2+
.NET Standard 2.0+
.NET Core 3.0+

PdfDocumentProcessor.AttachFile(PdfFileAttachment) Method

Attaches a file to the PDF document.

Namespace: DevExpress.Pdf

Assembly: DevExpress.Docs.v19.2.dll

Declaration

public void AttachFile(
    PdfFileAttachment attachment
)
Public Sub AttachFile(
    attachment As PdfFileAttachment
)
public void AttachFile(
    PdfFileAttachment attachment
)
Public Sub AttachFile(
    attachment As PdfFileAttachment
)
public void AttachFile(
    PdfFileAttachment attachment
)
Public Sub AttachFile(
    attachment As PdfFileAttachment
)

Parameters

Name Type Description
attachment PdfFileAttachment

A PdfFileAttachment object that contains settings to attach a file to the PDF document.

Parameters

Name Type Description
attachment PdfFileAttachment

A PdfFileAttachment object that contains settings to attach a file to the PDF document.

Parameters

Name Type Description
attachment PdfFileAttachment

A PdfFileAttachment object that contains settings to attach a file to the PDF document.

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.

Examples

This example shows how to programmatically attach a file to the PDF document.

To do this:

using DevExpress.Pdf;
using System;
using System.IO;

namespace AttachFile {
    class Program {
        static void Main(string[] args) {

            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");
            }
        }
    }
}
See Also