Hi all!, I wanted to know if it is possible to convert pdf files to images and then apply zoom to these pictures.
My application has a feature that shows pictures in preview, and we want to add the possibility of increasing the size of the pictures with double click, like a zoom.
It is possible convert pdf files to images and then apply zoom to these picture with Aspose?
We use Aspose for Java.
Best Regards
Martin Fernandez
Java Developer
Hi Martin,
// instantiate PdfPageEditor class to
get particular page region<o:p></o:p>
com.aspose.pdf.facades.PdfPageEditor editor = new com.aspose.pdf.facades.PdfPageEditor();
// bind the source PDF file
editor.bindPdf("c:\\pdftest\\OptimizedFile.pdf");
// set zoom over PDF file
editor.setZoom(2);
// save the PDF file to temporary location
editor.save("c:/pdftest/ZoomLeverChanged.pdf");
//open document
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document("c:/pdftest/ZoomLeverChanged.pdf");
// create stream object to save the output image
java.io.OutputStream imageStream = new java.io.FileOutputStream("c:/pdftest/New_Converted_Image.jpg");
//create JPEG device with specified attributes
//Quality [0-100], 100 is Maximum
//create Resolution object
com.aspose.pdf.Resolution resolution = new com.aspose.pdf.Resolution(300);
//create JpegDevice object where second argument indicates the quality of resultant image
com.aspose.pdf.JpegDevice jpegDevice = new com.aspose.pdf.JpegDevice(resolution, 100);
//convert a particular page and save the image to stream
jpegDevice.process(pdfDocument.getPages().get_Item(1), imageStream);
//close the stream
imageStream.close();
Hi Nayyer, thank you very much for your help, now I’m converting pdf images with zoom, but now the images created, some of them appears in black, as you can see in the attachments.
Hi, I want to know if you have any news about this topic.
I updated to the last version of Aspose pdf (aspose.pdf-new-4.1.0) but the problem continues.
Hi Martin,
Can you please share some details regarding your working environment. We are sorry for your inconvenience.
Hi, thanks for the answer, Do you tested with the code snippet that I send you?
My environment is also win7 64bit, eclipse Juno but Java 6.
I tried with versions 4.0.0 and 4.1.0 of Aspose.Pdf but for this last, I had to take the package related to Servlets because they gave me compatibility problems with other servlet library that we have in our project.
It could be the resolution?
I will keep trying, if you have something to suggest me, will be welcome.
Best Regards
Martin Fernandez
Java Developer
Hi Martin,