将Pdf文件转换为tiff文件

时间:2015-08-20 14:15:47

标签: pdf tiff

我使用了www.jcgonzalez.com/img/0/75/libraries.zip这个库,这里是我的代码

 public static void pdfconverter(String FILEPATH){

     Document document = new Document();

          try {
             document.setFile(FILEPATH);
          } catch (PDFException ex) {
             System.out.println("Error parsing PDF document " + ex);
          } catch (PDFSecurityException ex) {
             System.out.println("Error encryption not supported " + ex);
          } catch (FileNotFoundException ex) {
             System.out.println("Error file not found " + ex);
          } catch (IOException ex) {
             System.out.println("Error IOException " + ex);
          }
          float scale = 1.0f;
          float rotation = 0f;
          for (int i = 0; i < document.getNumberOfPages(); i++) {
             BufferedImage image = (BufferedImage) document.getPageImage(
                 i, GraphicsRenderingHints.PRINT, Page.BOUNDARY_CROPBOX, rotation, scale);
             RenderedImage rendImage = image;
             try {
                System.out.println(" capturing page " + i);
                File file = new File("imageCapture1_" + i + ".tif");
                ImageIO.write(rendImage, "tiff", file);
             } catch (IOException e) {
                e.printStackTrace();
             }
             image.flush();
          }
          document.dispose();


    }

但是图像显示的是方形而不是'ş'。知道为什么吗?

0 个答案:

没有答案