错误:Exception in thread "main" java.io.IOException: Unknown encoding for 'Identity-V'
错误代码:
package org.pdf;
import java.io.FileInputStream;
import org.pdfbox.pdfparser.PDFParser;
import org.pdfbox.pdmodel.PDDocument;
import org.pdfbox.util.PDFTextStripper;
public class Test_pdf {
@SuppressWarnings("deprecation")
public static void main(String[] args) throws Exception {
FileInputStream fis = new FileInputStream("D:\\struts2权威指南.pdf");
//BufferedWriter writer = new BufferedWriter(new FileWriter("F:\\task\\pdf_change.txt"));
PDFParser parser = new PDFParser(fis);
// 对PDF文件进行解析
parser.parse();
// 获取解析后得到的PDF文档对象
PDDocument pdfdocument = parser.getPDDocument();
PDFTextStripper stripper = new PDFTextStripper();
// 从PDF文档对象中剥离文本
String s = stripper.getText(pdfdocument);
s= new String(s.getBytes("iso8859-1"), "utf-8");
System.out.println(s);
//writer.close();
}
}
该贴由koei123转至本版2015-6-1 14:53:24