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
A good starting point would by PDFDraw sample project:
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: