How to convert pdf to image ??

Last post 07-02-2009, 12:17 PM by shahzad.latif. 7 replies.
Sort Posts: Previous Next
  •  07-01-2009, 6:53 AM 186350

    How to convert pdf to image ?? Java

    Hi I am getting exception when i used this code snnipet. My task is to make pdf  as image. Each page in the pdf file will create single single image. but after executing this one i got some exception.

     

    public class MyServlet extends HttpServlet{

    String inFile = "D://over.pdf";

    public void init(){ }

    public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {

    String pageName = request.getParameter("pageNo");

    try{

    PdfConverter converter = new PdfConverter();

    converter.bindPdf(inFile);

    converter.doConvert();

    String suffix = ".jpg";

    int imageCount = 1;

    while (converter.hasNextImage()) {

    converter.getNextImage("D://" + imageCount + suffix);

    imageCount++;

    }

    }

    catch (Exception e) {e.printStackTrace();}

    }

    }

    -----------------------------------------------------

    The exception is

    java.lang.ExceptionInInitializerError
    java.lang.J9VMInternals.initialize(J9VMInternals.java:195)
    java.lang.J9VMInternals.initialize(J9VMInternals.java:144)
    com.aspose.pdf.kit.oi.<clinit>(Unknown Source)
    java.lang.J9VMInternals.initializeImpl(Native Method)
    java.lang.J9VMInternals.initialize(J9VMInternals.java:177)
    com.aspose.pdf.kit.PDFont.getEncoding(Unknown Source)
    com.aspose.pdf.kit.PDFont.encode(Unknown Source)
    com.aspose.pdf.kit.mw.a(Unknown Source)
    com.aspose.pdf.kit.fh.a(Unknown Source)
    com.aspose.pdf.kit.mw.a(Unknown Source)
    com.aspose.pdf.kit.mw.a(Unknown Source)
    com.aspose.pdf.kit.bs.a(Unknown Source)
    com.aspose.pdf.kit.mw.if(Unknown Source)
    com.aspose.pdf.kit.mw.a(Unknown Source)
    com.aspose.pdf.kit.bs.a(Unknown Source)
    com.aspose.pdf.kit.q7.fD(Unknown Source)
    com.aspose.pdf.kit.PdfConverter.doConvert(Unknown Source)
    com.MyServlet.doGet(MyServlet.java:43)

     
  •  07-01-2009, 8:21 AM 186382 in reply to 186350

    Re: How to convert pdf to image ??

    Hi,

    Thank you very much for considering Aspose.

    Can you please share the PDF file you're having problem with? Also, please mention the version of Aspose.Pdf.Kit you're using.

    We're sorry for the inconvenience.

    Regards,

     


    Shahzad Latif - [Follow me on Twitter!]
    Support Developer/Developer Evangelist
    Aspose Sialkot Team
    Aspose - Your File Format Experts

    Keep in touch! We're on Twitter and Facebook
     
  •  07-01-2009, 8:33 AM 186386 in reply to 186382

    Re: How to convert pdf to image ??

    I used simple pdf file. Only text file. and the latest version i download and used.
     
  •  07-01-2009, 9:12 AM 186402 in reply to 186386

    Re: How to convert pdf to image ??

    Hi,

    I have tested the issue at my end using a simple PDF containing text only. It worked fine at my end. Kindly, share the PDF file you're having problem with. This will help us understand whether the problem is with that particular file.

    We're sorry for the inconvenience.

    Regards,

     


    Shahzad Latif - [Follow me on Twitter!]
    Support Developer/Developer Evangelist
    Aspose Sialkot Team
    Aspose - Your File Format Experts

    Keep in touch! We're on Twitter and Facebook
     
  •  07-02-2009, 12:23 AM 186515 in reply to 186402

    Re: How to convert pdf to image ??

    Please provide me yours contact details so that i can send u the same.
     
  •  07-02-2009, 12:38 AM 186518 in reply to 186386

    Re: How to convert pdf to image ??

    My program is this one :

    public class TestProgram {

    public void getImageFunc(){

    try{

    String inFile = "D://partha.pdf";

    PdfConverter converter = new PdfConverter();

    converter.bindPdf(inFile);

    converter.doConvert();

    String suffix = ".jpg";

    int imageCount = 1;

    while (converter.hasNextImage()) {

    converter.getNextImage("D://" + imageCount + suffix);

    imageCount++;

    }

    }

    catch (Exception e) {

    // TODO: handle exception

    e.printStackTrace();

    }

    }

    public static void main(String[] args) {

    TestProgram testProgram = new TestProgram();

    testProgram.getImageFunc();

    }

    }

     

     

    I am Getting this error :

    Exception in thread "main" java.lang.NoClassDefFoundError: com.sun.media.jai.codec.SeekableStream

    at com.aspose.pdf.kit.e0.a(Unknown Source)

    at com.aspose.pdf.kit.PdfConverter.a(Unknown Source)

    at com.aspose.pdf.kit.PdfConverter.getNextImage(Unknown Source)

    at com.aspose.pdf.kit.PdfConverter.getNextImage(Unknown Source)

    at com.TestProgram.getImageFunc(TestProgram.java:15)

    at com.TestProgram.main(TestProgram.java:27)

     
  •  07-02-2009, 1:21 AM 186523 in reply to 186518

    Re: How to convert pdf to image ??

    Hi,

    Please go to Contact option on this post and then click Send Shahzad.Latif an email. It'll open the window which will let you send an email along with the attachment. Alternatively, you can attach the file with your reply post and mark the post as Private. This will not allow anyone to view the attachment other than Aspose staff.

    I hope this helps.

    Regards,

     


    Shahzad Latif - [Follow me on Twitter!]
    Support Developer/Developer Evangelist
    Aspose Sialkot Team
    Aspose - Your File Format Experts

    Keep in touch! We're on Twitter and Facebook
     
  •  07-02-2009, 12:17 PM 186631 in reply to 186523

    Re: How to convert pdf to image ??

    Hi,

    I have tested the issue at my end. In fact, your code is fine, however you need to use Java Advanced Imaging API. This library contains the com.sun.media.jai.codec.SeekableStream class.

    I hope this helps. If you still find any further issues please do let us know.

    Regards,

     


    Shahzad Latif - [Follow me on Twitter!]
    Support Developer/Developer Evangelist
    Aspose Sialkot Team
    Aspose - Your File Format Experts

    Keep in touch! We're on Twitter and Facebook
     
View as RSS news feed in XML