Back to Devexpress

PdfFileAttachment.FileName Property

officefileapi-devexpress-dot-pdf-dot-pdffileattachment-75a0e6ba.md

latest2.8 KB
Original Source

PdfFileAttachment.FileName Property

SECURITY-RELATED CONSIDERATIONS

Using file paths sourced from untrusted input may expose unauthorized files or allow unintended file access. Always validate and normalize all external paths to prevent path manipulation.

Gets or sets the attached file name.

Namespace : DevExpress.Pdf

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

NuGet Package : DevExpress.Pdf.Core

Declaration

csharp
public string FileName { get; set; }
vb
Public Property FileName As String

Property Value

TypeDescription
String

A string value that is the name of an attached file.

|

Example

View Example

csharp
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 attached file.",
        FileName = "MyAttach.txt",
        Data = File.ReadAllBytes("..\\..\\..\\FileToAttach.txt"),
        MimeType = "text/plain",
        Relationship = PdfAssociatedFileRelationship.Supplement,
    });

    // The attached document.
    processor.SaveDocument("..\\..\\Result.pdf");
}
vb
Imports DevExpress.Pdf
Imports System
Imports System.IO

Shared Sub Main(ByVal args() As String)

    Using processor As New PdfDocumentProcessor()
        ' Load a document.
        processor.LoadDocument("..\..\Document.pdf")

        ' Attach a file to the PDF document. 
        processor.AttachFile(New PdfFileAttachment() With { _
            .CreationDate = Date.Now, _
            .Description = "This is my attached file.", _
            .FileName = "MyAttach.txt", _
            .Data = File.ReadAllBytes("..\..\FileToAttach.txt"), _
            .MimeType = "text/plain",
            .Relationship = PdfAssociatedFileRelationship.Supplement
        })

        ' The attached document.
        processor.SaveDocument("..\..\Result.pdf")
    End Using
End Sub

See Also

PdfFileAttachment Class

PdfFileAttachment Members

DevExpress.Pdf Namespace