try {
document = PDDocument.load(file);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
output = new OutputStreamWriter(baos);
stripper = new PDFTextStripper();
stripper.writeText(document, output);
return baos.toString();
} catch (MalformedURLException e) {
throw e;
} finally {
output.close();
}
document.close();
}
}复制代码
下边资料是关于java PDF文件解析成String的内容。