DocumentPackageCustomParts Property

Gets or sets the collection of custom parts (arbitrary content) that are linked to the OOXML package using "unknown relationships".

Namespace:  Aspose.Words
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 20.7.0


public CustomPartCollection PackageCustomParts { get; set; }

Property Value

Type: CustomPartCollection


Do not confuse these custom parts with Custom XML Data. If you need to access Custom XML parts, use the CustomXmlParts property.

This collection contains OOXML parts whose parent is the OOXML package and they targets are of an "unknown relationship". For more information see CustomPart.

Aspose.Words loads and saves custom parts into OOXML documents only.

This property cannot be null.


Shows how to open a document with custom parts and access them.
// Open a document that contains custom parts
// CustomParts are arbitrary content OOXML parts
// Not to be confused with Custom XML data which is represented by CustomXmlParts
// This part is internal, meaning it is contained inside the OOXML package
Document doc = new Document(MyDir + "Custom parts OOXML package.docx");

// Clone the second part
CustomPart clonedPart = doc.PackageCustomParts[1].Clone();

// Add the clone to the collection

// Use an enumerator to print information about the contents of each part 
using (IEnumerator<CustomPart> enumerator = doc.PackageCustomParts.GetEnumerator())
    int index = 0;
    while (enumerator.MoveNext())
        Console.WriteLine($"Part index {index}:");
        Console.WriteLine($"\tName: {enumerator.Current.Name}");
        Console.WriteLine($"\tContentType: {enumerator.Current.ContentType}");
        Console.WriteLine($"\tRelationshipType: {enumerator.Current.RelationshipType}");
            ? "\tSourced from outside the document"
            : $"\tSourced from within the document, length: {enumerator.Current.Data.Length} bytes");

// The parts collection can have individual entries removed or be cleared like this

See Also