How do I get DeviceN colorants? How do I edit coloants in an existing PDF page?

Q:

I have a device_n colorspace. Fillcolorspace returns device_n which contains an array of names but how do I find what are there colorants?

Also, can I use PDFNet to edit/change PDF content stream from

… /CS1 cs 1 1 1 1 1 1 1 1 scn

to

… /CS1 cs 0 0 0 0 0 0 0 0 scn

A:

To extract DeviceN colorant names you can use the following snippet:

// The names parameter shall be an array of name objects specifying the individual
// colour components. The length of the array shall determine the number of components in the
// DeviceN colour space, which is subject to an implementation limit.
ColorSpace device_n = …
Obj cs = device_n.GetSDFObj();
Obj names = cs.GetAt(1);
int component_num = names.Size();
for (int i=0; i< component_num; ++i) {
string n = names.GetAt(i).GetName()
}

Also is there a way to change … /CS1 cs …

Yes, use the approach shown in ElementEdit sample (i.e. you would change the fill colorants to ColorPt(0,0,0,…)).