How to use PDFDraw and Export function to produce a gray scale TIF (8 bpp)?

Q:
How to use PDFDraw and export function to produce a gray scale TIF (8
bpp)?
---
A:
To produce grayscale image you could specify 'ColorSpace' parameter as
a hint in the pdfdraw.Export() method. For example:

// In C++
Dict enc_param;
enc_param.Put("ColorSpace", new Name("Gray"));
pdfdraw.Export(page, filename, "TIFF", &enc_param);

// In C#
Dict enc_param = Obj.CreateDict();
enc_param.Put("ColorSpace", Obj.CreateName("Gray"));
pdfdraw.Export(page, filename, "TIFF", enc_param);