How do I export color PDF pages to black and white / grayscale TIF files (in Java or C#)?

Q: How do I export color PDF pages to black and white / grayscale TIF
files?
-----
A: To export monochrome, G4 compressed TIFF images you need to specify
"BPC" parameter in the optional render 'hints' object. For example:

// Assuming Java... for C# simply replace first letters in function
// calls to capital letters.

// Initialize render 'gray_hint' parameter, that is used to control
the
// rendering process. In this case we tell the rasterizer to export
the image as
// 1 Bit Per Component (BPC) image.
// Note: Obj & ObjSet are located in the pdftron.SDF namespace
ObjSet hint_set=new ObjSet();
Obj mono_hint=hint_set.createDict();
mono_hint.putNumber("BPC", 1);

pdfdraw.setImageSize(1000, 1000); // Set the output image to be 1000
wide and 1000 pixels tall
pdfdraw.export(page, "out.tif"), "TIF", mono_hint);

Similarly you can render the PDF page in grayscale as follows:

// 'gray_hint' will tell the rasterizer to export the image as
grayscale.
Obj gray_hint=hint_set.createDict();
gray_hint.putName("ColorSpace", "Gray");
pdfdraw.export(page, "out2.tif", "TIF", gray_hint);

Please note that the same hint object can be reused in any number of
export operations, so you don't need to keep on initializing hint
object for each export operation.