PdfEmbeddedFile Class

A file embedded in a document (ISO 32000-2, 7.11.4): a file specification dictionary whose embedded file stream holds the bytes of the file. The files of the document are in PdfDocument.EmbeddedFiles, the files of a page in its file attachment annotations (PdfFileAttachmentAnnotation).

public sealed class PdfEmbeddedFile

Properties

NameDescription
CreationDateGets the date the file was created (/Params /CreationDate), or null.
DescriptionGets the description of the file (/Desc), or null.
DictionaryGets the file specification dictionary.
FileNameGets the name of the file: /UF, or /F, or the key of the name tree of the document.
MimeTypeGets the MIME type of the file (/Subtype of the embedded file stream), or null.
ModificationDateGets the date the file was last modified (/Params /ModDate), or null.
ReferenceGets the reference to the file specification, or null for a direct object.
RelationshipGets how the file relates to the content of the document (/AFRelationship); PdfAssociatedFileRelationship.Unspecified when it is missing or unknown.
SizeGets the size of the file in bytes (/Params /Size), or null when the file does not give it.

CreationDate

PdfEmbeddedFile.cs

Gets the date the file was created (/Params /CreationDate), or null.

public DateTimeOffset? CreationDate { get; }

Property value

DateTimeOffset?

Gets the description of the file (/Desc), or null.

public string? Description { get; }

Property value

string?

Gets the file specification dictionary.

public PdfDictionary Dictionary { get; }

Property value

PdfDictionary

Gets the name of the file: /UF, or /F, or the key of the name tree of the document.

public string FileName { get; }

Property value

string

Gets the MIME type of the file (/Subtype of the embedded file stream), or null.

public string? MimeType { get; }

Property value

string?

ModificationDate

PdfEmbeddedFile.cs

Gets the date the file was last modified (/Params /ModDate), or null.

public DateTimeOffset? ModificationDate { get; }

Property value

DateTimeOffset?

Gets the reference to the file specification, or null for a direct object.

public PdfReference? Reference { get; }

Property value

PdfReference?

Relationship

PdfEmbeddedFile.cs

Gets how the file relates to the content of the document (/AFRelationship); PdfAssociatedFileRelationship.Unspecified when it is missing or unknown.

public PdfAssociatedFileRelationship Relationship { get; }

Gets the size of the file in bytes (/Params /Size), or null when the file does not give it.

public long? Size { get; }

Property value

long?

Methods

NameDescription
GetData()Gets the content of the file.
GetPortfolioValue(string)Gets the value of a field of the portfolio for this file (/CI, ISO 32000-2, 12.3.5): a String, a Double, or a DateTimeOffset for a date field of the schema; null when the file has none.
SetPortfolioValue(string, DateTimeOffset)Sets the date of a field of the portfolio for this file (/CI).
SetPortfolioValue(string, double)Sets the number of a field of the portfolio for this file (/CI).
SetPortfolioValue(string, string?)Sets the text of a field of the portfolio for this file (/CI), or removes it.

Gets the content of the file.

public byte[] GetData()

Returns

byte[] The bytes of the file.

Exceptions

InvalidPdfContentException
The file specification has no embedded file stream, or the stream cannot be decoded.
PdfResourceLimitException
The decoded file exceeds PdfReadOptions.MaxDecodedStreamLength.

GetPortfolioValue(string)

PdfEmbeddedFile.cs

Gets the value of a field of the portfolio for this file (/CI, ISO 32000-2, 12.3.5): a String, a Double, or a DateTimeOffset for a date field of the schema; null when the file has none.

public object? GetPortfolioValue(string key)

Parameters

key string
The key of the field (PdfPortfolioField.Key).

Returns

object? The value.

SetPortfolioValue overloads

SetPortfolioValue(string, DateTimeOffset)

PdfEmbeddedFile.cs

Sets the date of a field of the portfolio for this file (/CI).

public void SetPortfolioValue(string key, DateTimeOffset value)
Parameters
key string
The key of the field.
value DateTimeOffset
The date.

SetPortfolioValue(string, double)

PdfEmbeddedFile.cs

Sets the number of a field of the portfolio for this file (/CI).

public void SetPortfolioValue(string key, double value)
Parameters
key string
The key of the field.
value double
The number.

SetPortfolioValue(string, string?)

PdfEmbeddedFile.cs

Sets the text of a field of the portfolio for this file (/CI), or removes it.

public void SetPortfolioValue(string key, string? value)
Parameters
key string
The key of the field.
value string?
The text, or null to remove the value.