*/
public Reader extractText(InputStream stream,
String type,
String encoding) throws IOException {
try {
PDFParser parser = new PDFParser(new BufferedInputStream(stream));
try {
parser.parse();
PDDocument document = parser.getPDDocument();
CharArrayWriter writer = new CharArrayWriter();
PDFTextStripper stripper = new PDFTextStripper();
stripper.setLineSeparator("\n");
stripper.writeText(document, writer);
return new CharArrayReader(writer.toCharArray());
} finally {
try {
PDDocument doc = parser.getPDDocument();
if (doc != null) {
doc.close();
}
} catch (IOException e) {
// ignore