Class PdfAttachment
public class PdfAttachment
- Inheritance
-
PdfAttachment
- Inherited Members
Methods
GetFile()
Retrieves the file contents of the PDF attachment as a byte array.
public byte[] GetFile()
Returns
- byte[]
A byte array containing the file contents of the PDF attachment. Returns an empty array if the file is not available.
Remarks
This method performs two passes to retrieve the file contents. The first pass determines the required buffer size, and the second pass reads the actual data into the buffer. If the file cannot be retrieved, an empty byte array is returned.
Exceptions
- dotPDFiumException
Thrown if the file contents cannot be retrieved during the second pass.
GetName()
Retrieves the name of the PDF attachment.
public string GetName()
Returns
- string
A string containing the name of the attachment. Returns an empty string if the name is not available.
Remarks
The returned string excludes any null terminator that may be present in the underlying data.
GetStringValue(string)
Retrieves the string value associated with the specified key from the attachment.
public string GetStringValue(string key)
Parameters
Returns
- string
The string value associated with the specified key, or an empty string if the key does not exist or the value is empty.
GetSubtype()
Retrieves the subtype of the PDF attachment.
public string GetSubtype()
Returns
- string
A string representing the subtype of the attachment. Returns an empty string if the subtype is not defined or cannot be retrieved.
Remarks
The subtype typically provides additional information about the attachment's type or purpose.
GetValueType(string)
Retrieves the type of value associated with the specified key in the attachment.
public AttachmentValueType GetValueType(string key)
Parameters
Returns
- AttachmentValueType
The AttachmentValueType representing the type of the value associated with the specified key.
HasKey(string)
Determines whether the attachment contains a specific key.
public bool HasKey(string key)
Parameters
Returns
SetFile(byte[], PdfDocument)
Associates a file with the current PDF attachment.
public void SetFile(byte[] data, PdfDocument doc)
Parameters
data
byte[]The file data to associate with the attachment. Must not be null or empty.
doc
PdfDocumentThe PDF document to which the attachment belongs. Must not be null.
Remarks
This method sets the file data for the current attachment in the specified PDF document. The file data is passed as a byte array and must be valid and non-empty. If the operation fails, a dotPDFiumException is thrown.
Exceptions
- ArgumentException
Thrown if
data
is null or empty.- dotPDFiumException
Thrown if the file data could not be set on the attachment.
SetStringValue(string, string)
Sets a string value associated with the specified key.
public void SetStringValue(string key, string value)
Parameters
key
stringThe key identifying the value to set. Cannot be null or empty.
value
stringThe string value to associate with the specified key. Cannot be null.
Remarks
This method associates a string value with a given key. If the operation fails, an exception
is thrown. Ensure that both key
and value
are valid and non-null before
calling this method.
Exceptions
- dotPDFiumException
Thrown if the operation fails to set the string value for the specified key.