2009-10-20 2 views
0

글꼴 PDF가 포함 된 PDF를 보려면 Sun의 PDF Renderer 패키지를 사용하는 데 문제가 있습니다. 내 응용 프로그램에서 볼 수있는 PDF의 모든 페이지에서 BufferedImage를 만드는 다음 코드를 가지고 있으며 포함 된 글꼴이없는 경우 제대로 작동합니다. 그러나 PDF에 글꼴이 포함되어 있으면 텍스트가 표시되지 않습니다. 어떤 아이디어? 또한 Adobe의 PDF 뷰어에서 잘 열립니다.sun PDF 렌더러를 사용하여 글꼴이 포함 된 PDF를 표시합니다.

File f = new File("C:\\test.pdf"); 
FileChannel fc = new RandomAccessFile(f, "r").getChannel(); 
PDFFile pdfFile = new PDFFile(fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size())); 
for(int x=0; x<pdfFile.getNumPages(); x++) { 
    try { 
     BufferedImage bi = (BufferedImage)pdfFile.getPage(x+1).getImage(
      (int)pdfFile.getPage(x+1).getWidth(), 
      (int)pdfFile.getPage(x+1).getHeight(), 
      new Rectangle((int)pdfFile.getPage(x+1).getWidth(), 
      (int)pdfFile.getPage(x+1).getHeight()), 
      null, true, true); 
    } 
    catch (Exception e) { 
     e.printStackTrace(); 
    } 
} 

답변

1

PDF 렌더러를 PDFRenderer에서 PDFBox로 변경하면 더 잘 작동합니다. 자세한 정보는 here입니다.

1

또한 오픈 소스 PDF 도구를 제공하는 Icesoft, IText, JPedal 및 Multivalent를 볼 수도 있습니다.

관련 문제