Here we add an image in its natural color space and then, at a
position down and to the right, converted to grayscale.
using var doc = new Doc();
doc.Rect.Pin = XRect.Corner.TopLeft;
doc.Rect.Magnify(0.5, 0.5);
string path = Server.MapPath("../mypics/mypic.jpg");
doc.AddImageFile(path, 1);
doc.Rect.Move(doc.Rect.Width, -doc.Rect.Height);
int i = doc.AddImageFile(path, 1);
var im = (ImageLayer)doc.ObjectSoup[i];
im.PixMap.ToGrayscale();
doc.Save(Server.MapPath("pixmaptograyscale.pdf"));
Using doc As New Doc()
doc.Rect.Pin = XRect.Corner.TopLeft
doc.Rect.Magnify(0.5, 0.5)
Dim thePath As String = Server.MapPath("../mypics/mypic.jpg")
doc.AddImageFile(thePath, 1)
doc.Rect.Move(doc.Rect.Width, -doc.Rect.Height)
Dim i As Integer = doc.AddImageFile(thePath, 1)
Dim im As ImageLayer = DirectCast(doc.ObjectSoup(i), ImageLayer)
im.PixMap.ToGrayscale()
doc.Save(Server.MapPath("pixmaptograyscale.pdf"))
End Using