officefileapi-devexpress-dot-pdf-dot-pdffileattachment-75a0e6ba.md
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
public string FileName { get; set; }
Public Property FileName As String
| Type | Description |
|---|---|
| String |
A string value that is the name of an attached file.
|
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");
}
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