All, Looking for newbie help. I searhed the internet looking for examples to follow. What I want to do is write code to read a multipage pdf and convert to jpg (each page) and display on screen. I find way too much stuff that is either complicated or it is already a package. All I want is to be able to follow simple examples. Thanks.

4 Years
Discussion Span
Last Post by Taywin

you can use like this:

//open document
com.aspose.pdf.Document pdfDocument = new com.aspose.pdf.Document("input.pdf");

// loop through all the pages of PDF file
for (int pageCount = 1; pageCount <= pdfDocument.getPages().size(); pageCount++)
// create stream object to save the output image
java.io.OutputStream imageStream = new java.io.FileOutputStream("Converted_Image" + pageCount + ".jpg");

//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(pageCount), imageStream);

//close the stream

ParPau: if you are a "newbie" in Java, then start at the beginning.

by copy-pasting code, you'll learn nothing except for just that: copy-pasting.


Daemon - thanks for the first reply. I think I did find something like your example. My difficulty was the "com.aspose.pdf.Document" and not knowing how to import it. This is something with which I am not familiar. I'm trying to follow examples from my book and they don't show anything like this. As for Stultuske, thanks for the sarcasm. I took a programming class at the community college. What I am trying now is to finish the last few chapters on my own. During the course, I was able to cut and paste some snippets and modify them to fit the homework. I learned by example. Can you please take your comment and shove them in the same place as your 5-1/2" floppy and Apple 2e? Insulting people who are trying to learn doesn't get you points. Feel good ? You're a "posting expert" with comments like that ? Featured as well ? Says a lot about what Daniweb has to offer.


OK, cool it down folks.
stultuske is well known for saying what he thinks. If anyone doesn't like his posts then just ignore them.

Please don't get into a place where I have to infract anyone for violating the "Keep it Pleasant" rule.
Now, back to the original subject please.

Edited by JamesCherrill


why go that way anyway... There's perfectly servicable libraries to show PDF documents in Swing (and I guess JavaFX) applications, as well as standard browser plugins to show them in web applications.


As Jwenting said there are free options such as iText, Apache PDFBox and others just search for them
Both of above mentioned libraries have very good documentation with plenty of examples and active communities to help out with issues one may face

Edited by peter_budo


The above post is an advertising. 1)pulled and old thread and 2)unrelating suggested solution.

Edited by Taywin

Votes + Comments
Thanks for the alert - action has been taken.
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.