Extract Pdf to memory stream in java

Dear all,

I have a license for Aspose.Total for java.

I want to extract PDF pages to images and store it on Memory Stream. And then recognize barcode for each images. Is it possible? There is no example for this in the DOCS.





Regards,
Carlo

Hi Carlo,


Thanks for your inquriy. Please note every method that uses file path have a overload with stream parameter as well. However we are preparing a sample code and will share with you shortly.

Best Regards,

Hi Carlo,

Adding more to Tilal’s comments, please notice following code snippet for converting PDF pages to Image and saving output in Stream object. Please take a look over following code snippet.

[Java]

Document pdfDocument = new Document("input.pdf");

for (int pageCount = 1; pageCount <= pdfDocument.getPages().size(); pageCount++) {
    java.io.OutputStream imageStream = new java.io.FileOutputStream("Converted_Image" + pageCount + ".jpg");
    Resolution resolution = new Resolution(300);
    com.aspose.pdf.devices.JpegDevice jpegDevice = new com.aspose.pdf.devices.JpegDevice(resolution, 100);
    jpegDevice.process(pdfDocument.getPages().get_Item(pageCount), imageStream);
    imageStream.close();
}