Skip to content

PDFDocumentFileAttachment

Namespace: O2S.Components.PDF4NET

Defines an attachment included in a PDF document.

public class PDFDocumentFileAttachment

Inheritance ObjectPDFDocumentFileAttachment

Constructors

PDFDocumentFileAttachment()

Initializes a new PDFDocumentFileAttachment object.

public PDFDocumentFileAttachment()

PDFDocumentFileAttachment(Byte[])

Initializes a new PDFDocumentFileAttachment object with the given content.

public PDFDocumentFileAttachment(Byte[] fileData)

Parameters

fileData Byte[]
The binary content to embed in the PDF file.


Properties

CreationDate

Gets or sets the creation date.

public DateTime CreationDate { get; set; }

Property Value

DateTime
The date and time when the attachment was created.


Description

Gets or sets the file description.

public string Description { get; set; }

Property Value

String
The description of the file attachment.


FileName

Gets or sets the file name.

public string FileName { get; set; }

Property Value

String
The file name corresponding to the content in PDFDocumentFileAttachment.Payload property.


MimeType

Gets or sets the MIME type.

public string MimeType { get; set; }

Property Value

String
The MIME type of the attachment.


ModifyDate

Gets or sets the modify date.

public DateTime ModifyDate { get; set; }

Property Value

DateTime
The date and time when the attachment was modified.


Payload

Gets or sets the attachment content.

public Byte[] Payload { get; set; }

Property Value

Byte[]
The content of the attachment.


RelationshipToOwner

Gets or sets the relationship between the file attachment and its owner.

public PDFDocumentFileAttachmentRelationship RelationshipToOwner { get; set; }

Property Value

PDFDocumentFileAttachmentRelationship
A PDFDocumentFileAttachmentRelationship enumeration member specifying how the file attachment is related to its owner.


Methods

GetPayloadStream()

Gets the decoded stream containing the content of the embedded file attachment, if available.

public Stream GetPayloadStream()

Returns

Stream
A stream representing the decoded content of the embedded file attachment, or null if no content is present.

Remarks

This method returns a stream representing the decoded content of the embedded file attachment. If the attachment content is not present or cannot be decoded, it returns null. The caller is responsible for disposing the returned stream when it is no longer needed.
The stream returned by this method is intended for reading the content of the embedded file attachment. Writing to the stream has no effect on the file attachment content. If you need to modify the content of the attachment, consider using the PDFDocumentFileAttachment.Payload property instead, which allows you to set the content as a byte array.
Use this method when dealing with large attachments as it avoids the byte array overhead of the PDFDocumentFileAttachment.Payload property and allows for more efficient memory usage when reading the content.