How do I parse/process PDF patterns?

Q: How do I get the array of pattern cells when FillColorSpace is
ColorSpace::e_pattern and TilingType is
PatternColor::e_colored_tiling_pattern?

In the API Reference, the description of Patterns implies that this
will be an array of color values (PatternColor) but I just can't
seem to find a way to get this array.
----
A: To better understand the pattern API it is a good idea to skim
through section 8.7 'Patterns' in PDF Reference (http://www.adobe.com/
devnet/acrobat/pdfs/PDF32000_2008.pdf). You can look at PDF patterns
as 'small PDF pages' that are tilled to fill-in the area of given path
or text element. The pattern can be composed on a sequence of vector
or image object, including text. A pattern may reference another
pattern, etc.

You can process patterns/shading that are used as a fill color as
follows (this pseudocode builds on ElementReaderAdv sample -
http://www.pdftron.com/net/samplecode.html#ElementReaderAdv):

// C# pseudocode...
static public void ProcessPath(Element path, ElementReader reader) {
       // This sample is only a minimal sketch illustrating how to
process patterns...
  if (path.IsFilled())
  {
    GState gs = path.GetGState();
    if (gs.GetFillColorSpace().GetType() == ColorSpace.Type.e_pattern)
    {
      PatternColor pat = gs.GetFillPattern();
      // In older versions of PDFNet you may need to instantiate
PatternColor
      // as follows: PatternColor pat = new PatternColor(gs.GetFillPattern
());
      PatternColor.Type type = pat.GetType();
      if (type == PatternColor.Type.e_shading)
      {
        Shading shading = pattern.GetShading();
        // ... ProcessShading(shading) ...
        return;
      }
      else if (type == PatternColor.Type.e_colored_tiling_pattern ||
        type == PatternColor.Type.e_uncolored_tiling_pattern)
      {
        // init_pat_gs is the graphics state that was in effect at the
beginning of the
        // pattern’s parent content stream.
        GState init_pat_gs = reader.PatternBegin(pat.GetSDFObj(),
true); // Open the pattern
        // ... Process tiling pattern
        ProcessTilingPattern(reader, pattern, ...);
        reader.End();
    }
    else
    {
      // ColorPt rgb = new ColorPt();
      // gs.GetFillColorSpace().Convert2RGB(gs.GetFillColor(), rgb);
    }
  }
  else
  {
    // Do not fill path
  }
}

If you would rather treat a pattern as a raster image object, you
could possibly use 'pdftron.PDF.PDFDraw' to render the bitmap for the
tile. In this you would need to coarce PDFNet to think that you have a
page object. Something along the following lines:

...
Obj pattern = pat.GetSDFObj();
pattern.Put("MediaBox", pattern.FindObj("BBox")); PDFDraw draw;
draw.Begin(page); draw.GetBitmap(); ...