1.使用pdfbox:

   代码如下:

public static void main(String[] args) {
        //第一种方式:
        String pdfPath = "d:\\深入理解.pdf";
        // config option 1:convert all document to p_w_picpath
        String[] args_1 = new String[3];
        args_1[0] = "-outputPrefix";
        args_1[1] = "my_p_w_picpath_1";
        args_1[2] = pdfPath;
        // 第二种方式
        String[] args_2 = new String[7];
        args_2[0] = "-startPage";
        args_2[1] = "1";
        args_2[2] = "-endPage";
        args_2[3] = "13";
        args_2[4] = "-outputPrefix";
        args_2[5] = "d:\\aa\\my_p_w_picpath";
        args_2[6] = pdfPath;
        try {
            // will output "my_p_w_picpath_1.jpg"
//          PDFToImage.main(args_1);
            // will output "my_p_w_picpath_2.jpg"
            PDFToImage.main(args_2);
        } catch (Exception e) {
//          logger.error(e.getMessage(), e);
            e.printStackTrace();
        }
    }



2.使用pdf renderer:


public static void main(String[] args) throws IOException {
            // TODO Auto-generated method stub
            File pdfFile = new File("d:\\深入理解.pdf");
            RandomAccessFile raf = new RandomAccessFile(pdfFile, "r");
            FileChannel channel = raf.getChannel();
            ByteBuffer buf = channel.map(FileChannel.MapMode.READ_ONLY, 0, channel.size());
            PDFFile pdf = new PDFFile(buf);
            for (int i=0; i 
  



jar包在网方下载