* @return Reader a reader that is fed to an indexer.
*/
protected Reader getReader(InputStream docStream)
{
PDFParser parser = null; PDDocument document = null; PDFTextStripper stripper = null;
CharArrayWriter writer = null;
try{
parser = new PDFParser(docStream);
parser.parse();
document = parser.getPDDocument();
writer = new CharArrayWriter();
stripper = new PDFTextStripper();
stripper.setLineSeparator("\n");
stripper.writeText(document, writer);
document.close();
writer.close();
parser.getDocument().close();
return new CharArrayReader(writer.toCharArray());
}catch (Exception e){
//logger.warn("WARNING: Problem converting PDF: ",e);
try{
document.close();
}catch(Exception e1){
//logger.warn("WARNING: Problem converting PDF: ",e1);
}
try{
writer.close();
}catch(Exception e2){
//logger.warn("WARNING: Problem converting PDF: ",e2);
}
try{
parser.getDocument().close();
}catch(Exception e3){
//logger.warn("WARNING: Problem converting PDF: ",e3);
}
parser = null; document = null; writer = null; stripper = null;
EOD=true;