How can I convert PDF to JPEG in JAVA without saving it to disk?

Q: I am using PDFNet SDK in JAVA.

How can I convert pdf to image (jpg) and save it to outputstream like
ByteOutputStream without saving it to disk?

I have tested :
OutputStream outputStream = new FileOutputStream(outputPath);
      doc.save(outputStream, SDFDoc.e_linearized, null);

but didn't work out
----------------------

A: Your code is saving PDF itself to a stream, and not the JPEG. You
would need to use pdftron.PDF.PDFDraw to render a specific PDF page to
an image.

A good starting point would by PDFDraw sample project:
  http://www.pdftron.com/pdfnet/samplecode.html#PDFDraw

Since you want to stream the rendered image you could obtain
java.awt.Image using pdfdraw.GetBitmap(), then stream the resulting
image to JPEG.

java.awt.Image image = draw.getBitmap(page);

To save the resulting image to JPEG you could use
‘javax.imageio.ImageIO’ or jai:

http://java.sun.com/products/java-media/jai/forDevelopers/jai1_0_1guide-unc/Encode.doc.html
http://www.java-forums.org/new-java/2790-how-save-image-jpg.html