Class FileAttachment
Inheritance
System.Object
FileAttachment
Assembly: IronPdf.dll
Syntax
public class FileAttachment : Object
Extracting a file embedded inside a PDF becomes straightforward with FileAttachment, the record that pairs an attachment's filename with the means to read its binary content. When IronPDF processes a PDF during SVG conversion, it surfaces each embedded file as a FileAttachment so the attachment's data can be retrieved without any additional parsing work.
Name exposes the filename stored in the PDF, such as "report.xlsx" or "signature.png", and serves as the natural key for routing or saving the attachment. GetContent opens a Stream over the attachment's bytes synchronously, accepting an optional CancellationToken for cooperative cancellation in long-running operations. GetContentAsync mirrors that behaviour asynchronously, returning Task<Stream> and fitting naturally into async/await pipelines where blocking the calling thread is undesirable. Both content methods return a fresh Stream each time, so the caller controls lifetime and disposal.
A typical pattern reads the stream and writes it to disk alongside the converted SVG output:
await using Stream content = await attachment.GetContentAsync();
await File.WriteAllBytesAsync(attachment.Name, await ReadAllBytesAsync(content));
For broader context on working with PDF attachments and conversion options, see the IronPDF documentation and the PDF to SVG how-to.
Properties
Name
Declaration
public string Name { get; }
Property Value
| Type |
Description |
| System.String |
|
Methods
GetContent(CancellationToken)
Declaration
public Stream GetContent(CancellationToken cancellationToken = null)
Parameters
| Type |
Name |
Description |
| System.Threading.CancellationToken |
cancellationToken |
|
Returns
| Type |
Description |
| System.IO.Stream |
|
GetContentAsync(CancellationToken)
Declaration
public Task<Stream> GetContentAsync(CancellationToken cancellationToken = null)
Parameters
| Type |
Name |
Description |
| System.Threading.CancellationToken |
cancellationToken |
|
Returns
| Type |
Description |
| System.Threading.Tasks.Task<System.IO.Stream> |
|