Back to Devexpress

PdfPageFacade.AddFileAttachmentAnnotation(PdfPoint, PdfFileAttachment, String) Method

officefileapi-devexpress-dot-pdf-dot-pdfpagefacade-dot-addfileattachmentannotation-x28-devexpress-dot-pdf-dot-pdfpoint-devexpress-dot-pdf-dot-pdffileattachment-system-dot-string-x29.md

latest4.2 KB
Original Source

PdfPageFacade.AddFileAttachmentAnnotation(PdfPoint, PdfFileAttachment, String) Method

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

Namespace : DevExpress.Pdf

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

NuGet Package : DevExpress.Pdf.Core

Declaration

csharp
public PdfFileAttachmentAnnotationFacade AddFileAttachmentAnnotation(
    PdfPoint point,
    PdfFileAttachment file,
    string iconName
)
vb
Public Function AddFileAttachmentAnnotation(
    point As PdfPoint,
    file As PdfFileAttachment,
    iconName As String
) As PdfFileAttachmentAnnotationFacade

Parameters

NameTypeDescription
pointPdfPoint

The point on the page to position the annotation.

| | file | PdfFileAttachment |

The file associated with this annotation.

|

Optional Parameters

NameTypeDefaultDescription
iconNameString"PushPin"

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

|

Returns

TypeDescription
PdfFileAttachmentAnnotationFacade

An object that contains file attachment annotation properties.

|

Example

The code sample below creates a file attachment annotation:

csharp
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");
}
vb
Using processor As New PdfDocumentProcessor()
  ' Load a document
  processor.LoadDocument("..\..\Document.pdf")

  ' Access the first page properties
  Dim pageFacade As PdfPageFacade = processor.DocumentFacade.Pages(0)

  ' Specify attachment data
  Dim attachment As New PdfFileAttachment()
  With {.CreationDate = Date.Now,
    .Description = "This is my attached file.",
    .FileName = "MyAttach.txt",
    .Data = File.ReadAllBytes("..\..\FileToAttach.txt")}

  ' Create a file attachment annotation
    Dim pdfFileAttachment As PdfFileAttachmentAnnotationFacade =
       pageFacade.AddFileAttachmentAnnotation(New PdfPoint(700,100), attachment,
         PdfFileAttachmentAnnotationIconName.PaperClip)
    pdfFileAttachment.Author = "Sabella Jaida"
    pdfFileAttachment.Subject = "Attachment"

  ' Save the result
  processor.SaveDocument("..\..\Result.pdf")
End Using

See Also

PdfPageFacade Class

PdfPageFacade Members

DevExpress.Pdf Namespace