Skip to main content
All docs
V23.2

PdfPageFacade.AddFileAttachmentAnnotation(PdfRectangle, PdfFileAttachment) Method

Adds a file attachment annotation in the specified page rectangle.

Namespace: DevExpress.Pdf

Assembly: DevExpress.Pdf.v23.2.Core.dll

NuGet Package: DevExpress.Pdf.Core

Declaration

public PdfFileAttachmentAnnotationFacade AddFileAttachmentAnnotation(
    PdfRectangle rect,
    PdfFileAttachment file
)

Parameters

Name Type Description
rect PdfRectangle

A page area to add the annotation.

file PdfFileAttachment

The file associated with this annotation.

Returns

Type Description
PdfFileAttachmentAnnotationFacade

An object that contains file attachment annotation properties.

Remarks

The code sample below creates a file attachment annotation:

using DevExpress.Pdf;
using System.IO;
//...
using (PdfDocumentProcessor processor = new PdfDocumentProcessor())
{
    // Load a document
    processor.LoadDocument("..\\..\\Document.pdf");

    // Access the first page properties
    PdfPageFacade pageFacade = processor.DocumentFacade.Pages[0];

    // Define an annotation area
    PdfRectangle pdfRectangle = new PdfRectangle(684, 152, 704, 172);

    // Specify attachment data
    PdfFileAttachment attachment = new PdfFileAttachment()
    {
        CreationDate = DateTime.Now,
        Description = "This is my attach file.",
        FileName = "MyAttach.txt",
        Data = File.ReadAllBytes("..\\..\\FileToAttach.txt")
    };

    // Create an annotation
    PdfFileAttachmentAnnotationFacade fileAttachmentAnnotation =
       pageFacade.AddFileAttachmentAnnotation(pdfRectangle, attachment);

    // Specify annotation properties
    fileAttachmentAnnotation.Author = "Sabella Jaida";
    fileAttachmentAnnotation.Subject = "File Attachment";

    // Save the result
    processor.SaveDocument("..\\..\\Result.pdf");
}
See Also