How do I create 'Spot Colors' using PDFNet?

Q:

I am interesed in learning more on how to create and work with 'Spot
Colors' using PDFNet. I need to convert the below code to generate a
Spot Colour instead of CMYK:

Element rect = builder.CreateRect(0, 0, 100, 100);
rect.SetPathStroke(true);
rect.GetGState().SetStrokeColorSpace(ColorSpace.CreateDeviceCMYK);
rect.GetGState().SetStrokeColor(new ColorPt(0, 1, 1, 0));
writer.WriteElement(rect);
-----
A:
Spot color can be represented in PDF using 'Separation' or 'DeviceN'
color spaces.

A separation color space can be treated similarly to grayscale color
space. For details on separation color space, please refer to section
4.5.5 'Special Color Spaces' in PDF Reference Manual (http://
www.pdftron.com/downloads/PDFReference16.pdf).

The following is a code snippet that illustrates how to create a
separation color space:

ColorSpace CreateSpotColorSpace(PDFDoc doc)
{
  Obj sep_cs = doc.CreateIndirectArray();
  sep_cs.PushBack(Obj.CreateName("Separation"));

  // The name of the colorant
  sep_cs.PushBack(Obj.CreateName("LogoGreen"));

  // Alternate color space
  sep_cs.PushBack(Obj.CreateName("DeviceCMYK"));

  // Create tint function (using PostScript calculator function).
  // Tint function is used to transform a tint value into color
  // component values in the alternate color space.
  string ps_funct = "{ dup 0.84 mul exch 0.00 exch dup 0.44 mul exch
0.21 mul }";
  Obj tint_funct = doc.CreateIndirectStream(new
System.Text.UTF8Encoding().GetBytes(ps_funct));
  tint_funct.Put("FunctionType", Obj.CreateNumber(4));
  tint_funct.Put("FunctionType", Obj.CreateNumber(4));

  Obj tint_domain = Obj.CreateArray();
  tint_domain.PushBack(Obj.CreateNumber(0)); // Gray
  tint_domain.PushBack(Obj.CreateNumber(1));
  tint_funct.Put("Domain", tint_domain);

  Obj tint_range = Obj.CreateArray();
  tint_range.PushBack(Obj.CreateNumber(0)); // C
  tint_range.PushBack(Obj.CreateNumber(1));
  tint_range.PushBack(Obj.CreateNumber(0)); // M
  tint_range.PushBack(Obj.CreateNumber(1));
  tint_range.PushBack(Obj.CreateNumber(0)); // Y
  tint_range.PushBack(Obj.CreateNumber(1));
  tint_range.PushBack(Obj.CreateNumber(0)); // K
  tint_range.PushBack(Obj.CreateNumber(1));
  tint_funct.Put("Range", tint_range);

  sep_cs.PushBack(tint_range);
  return ColorSpace(sep_cs);
}

The resulting color space can then be reused throughout a PDF
document. For example:

ColorSpace cs = CreateSpotColorSpace(doc);
...
Element rect = builder.CreateRect(0, 0, 100, 100);
rect.SetPathStroke(true);
rect.GetGState().SetStrokeColorSpace(cs);
rect.GetGState().SetStrokeColor(new ColorPt(1));
writer.WriteElement(rect);

There were a couple of typos in the above code. The correct function
to create a custom Sepeatation (i.e. Spot) color space is as follows:

static ColorSpace CreateSpotColorSpace(PDFDoc doc)
{
  Obj sep_cs = doc.CreateIndirectArray();
  sep_cs.PushBack(Obj.CreateName("Separation"));

  // The name of the colorant
  sep_cs.PushBack(Obj.CreateName("LogoGreen"));

  // Alternate color space
  sep_cs.PushBack(Obj.CreateName("DeviceCMYK"));

  // Create tint function (using PostScript calculator function).
  // Tint function is used to transform a tint value into color
  // component values in the alternate color space.
  string ps_funct = "{ dup 0.84 mul exch 0.00 exch dup 0.44 mul exch
0.21 mul }";
  Obj tint_funct = doc.CreateIndirectStream(new
System.Text.UTF8Encoding().GetBytes(ps_funct));
  tint_funct.Put("FunctionType", Obj.CreateNumber(4));

  Obj tint_domain = Obj.CreateArray();
  tint_domain.PushBack(Obj.CreateNumber(0)); // Gray
  tint_domain.PushBack(Obj.CreateNumber(1));
  tint_funct.Put("Domain", tint_domain);

  Obj tint_range = Obj.CreateArray();
  tint_range.PushBack(Obj.CreateNumber(0)); // C
  tint_range.PushBack(Obj.CreateNumber(1));
  tint_range.PushBack(Obj.CreateNumber(0)); // M
  tint_range.PushBack(Obj.CreateNumber(1));
  tint_range.PushBack(Obj.CreateNumber(0)); // Y
  tint_range.PushBack(Obj.CreateNumber(1));
  tint_range.PushBack(Obj.CreateNumber(0)); // K
  tint_range.PushBack(Obj.CreateNumber(1));
  tint_funct.Put("Range", tint_range);

  sep_cs.PushBack(tint_funct);
  return new ColorSpace(sep_cs);
}

The resulting color space can be reused throughout the PDF document.
For example:

ColorSpace cs = CreateSpotColorSpace(doc);
...
Element rect = builder.CreateRect(0, 0, 100, 100);
rect.SetPathStroke(true);
rect.GetGState().SetStrokeColorSpace(cs);
rect.GetGState().SetStrokeColor(new ColorPt(1));
writer.WriteElement(rect);