ClassEmbeddedFilesCollection
Attachment store for embedded files; add, rename, and remove files, with single ZUGFeRD/Factur‑X invoice support when present.
Definition
Namespace:Telerik.Windows.Documents.Fixed.Model.Collections
Assembly:Telerik.Windows.Documents.Fixed.dll
Syntax:
public sealed class EmbeddedFilesCollection : NamedCollectionBase<EmbeddedFile>, IEnumerable<EmbeddedFile>, IEnumerable
Inheritance: objectNamedCollectionBase<EmbeddedFile>EmbeddedFilesCollection
Implements:
Properties
ContainsZugferdInvoice
Indicates whether the collection contains a ZUGFeRD (or Factur‑X) invoice file.
Declaration
public bool ContainsZugferdInvoice { get; }
Property Value
True if the collection contains a ZUGFeRD invoice file; otherwise, false.
Count
Number of embedded files in the collection.
Names
Collection of names of the embedded files.
Declaration
public IEnumerable<string> Names { get; }
Property Value
this[string]
Get the embedded file associated with the specified name.
Declaration
public EmbeddedFile this[string name] { get; }
Parameters
name
The name of the embedded file to retrieve.
Property Value
The embedded file with the specified name.
Exceptions
Thrown when no embedded file with the specified name exists in the collection.
Methods
Add(string, byte[])
Creates and adds a new embedded file with the specified name and binary data to the collection.
Declaration
public EmbeddedFile Add(string name, byte[] data)
Parameters
name
The name to assign to the embedded file.
data
byte[]
The binary data content of the embedded file.
Returns
The newly created embedded file instance.
Exceptions
Thrown when the name is null or empty.
Thrown when the data is null.
DuplicatedEmbeddedFileNameException
Thrown when an embedded file with the same name already exists in the collection.
AddZugferdInvoice(byte[], ZugferdConformanceLevel)
Creates and adds a ZUGFeRD-compliant embedded invoice file to the collection with basic conformance level.
Declaration
public EmbeddedFile AddZugferdInvoice(byte[] data, ZugferdConformanceLevel level = ZugferdConformanceLevel.Basic)
Parameters
data
byte[]
The raw XML bytes of the invoice to embed. This should contain a valid ZUGFeRD/Factur-X compliant XML document.
level
The ZUGFeRD/Factur-X conformance level to apply when exporting the PDF. Defaults to Basic. Supported values are Minimum, Basic, Comfort and Extended.
Returns
The newly created embedded file representing the invoice.
Exceptions
Thrown when data is null.
Thrown when an invoice attachment is already present. Only one ZUGFeRD/Factur-X invoice per document is allowed.
Remarks
- If an invoice already exists (detected by common invoice filenames such as "ZUGFeRD-invoice.xml", "zugferd-invoice.xml"), the method throws.
- The specified
levelis stored in the collection and used during PDF export. - To replace an existing invoice, call RemoveZugferdInvoice() before adding a new one.
Clear()
Removes all embedded files from the collection.
Declaration
public void Clear()
ContainsName(string)
Determines whether an embedded file with the specified name exists in the collection.
Declaration
public bool ContainsName(string name)
Parameters
name
The name to search for in the collection.
Returns
True if an embedded file with the specified name exists; otherwise, false.
Exceptions
Thrown when the name parameter is null.
GetEnumerator()
Returns an enumerator that iterates through the collection.
Declaration
public override IEnumerator<EmbeddedFile> GetEnumerator()
Returns
An enumerator for the collection.
Overrides
IncrementFileNameOverride(ref int, string[], string, string)
Generates an incremented version of the provided name if it already exists in the collection.
Declaration
protected override string IncrementFileNameOverride(ref int counter, string[] splitName, string fileName, string newName)
Parameters
counter
The current counter value used for generating unique suffixes.
splitName
string[]
The name components split by dot separators.
fileName
The base file name without extension or numeric suffix.
newName
The candidate new name to check for uniqueness.
Returns
A unique name that doesn't conflict with existing names in the collection.
Overrides
Remove(string)
Removes the embedded file with the specified name from the collection and cleans up its parent associations.
Declaration
public bool Remove(string name)
Parameters
name
The name of the embedded file to remove.
Returns
True if the embedded file was successfully found and removed; otherwise, false.
Exceptions
Thrown when the name parameter is null.
RemoveZugferdInvoice()
Removes all ZUGFeRD invoice files from the collection.
Declaration
public bool RemoveZugferdInvoice()
Returns
True if any ZUGFeRD invoice files were successfully found and removed; otherwise, false.
Rename(string, string)
Changes the name of an existing embedded file in the collection.
VerifyCollectionLimit()
Verifies that the collection has not exceeded its maximum capacity limit.
Declaration
protected override void VerifyCollectionLimit()
Exceptions
Thrown when the collection size exceeds the maximum allowed limit.
Overrides