Skip to main content
A newer version of this page is available. .
All docs
V21.2
.NET Framework 4.5.2+

PdfPageFacade.AddFileAttachmentAnnotation(PdfPoint, PdfFileAttachment, String) Method

Creates a file attachment annotation at the specified point on the page.

Namespace: DevExpress.Pdf

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

NuGet Package: DevExpress.Pdf.Core

Declaration

public PdfFileAttachmentAnnotationFacade AddFileAttachmentAnnotation(
    PdfPoint point,
    PdfFileAttachment file,
    string iconName
)

Parameters

Name Type Description
point PdfPoint

The point on the page to position the annotation.

file PdfFileAttachment

The file associated with this annotation.

Optional Parameters

Name Type Default Description
iconName String "PushPin"

The name of the annotation icon. Use the PdfFileAttachmentAnnotationIconName class fields to specify a built-in icon.

Returns

Type Description
PdfFileAttachmentAnnotationFacade

An object that contains file attachment annotation properties.

Example

The code sample below creates a file attachment annotation:

file attachment annotation

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

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

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

    // Create a file attachment annotation
    PdfFileAttachmentAnnotationFacade pdfFileAttachment =
        pageFacade.AddFileAttachmentAnnotation
            (new PdfPoint(700,100), attachment, PdfFileAttachmentAnnotationIconName.PaperClip);
    pdfFileAttachment.Author = "Sabella Jaida";
    pdfFileAttachment.Subject = "Attachment";

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