How do I convert XPS to Image on the fly?

Q:

I need to convert XPS to Image on the fly. I mean a byte array as xps, and exporting a byte array of image.

Can I do this with PDFNet? on all platforms - Windows, Mac, Linux, mobile ?

A:

Yes, you can do this with along the following lines:

PDFDoc doc = new PDFDoc();

Convert.FromXps(doc, buf, buf_size);

PDFDraw draw = new PDFDraw();

for (PageIterator itr=doc.GetPageIterator(); itr.HasNext(); itr.Next()) {

string outname = string.Format("{0}newsletter{1:d}.jpg", output_path, itr.GetPageNumber());

Bitmap bmp=draw.GetBitmap(itr.Current());

}

Apart from syntax issues you can do the same on Java, .NET, C/C++, Obj-C, Pyhon, Android, etc.