PDDocument pdDoc= parser.getPDDocument();
StringWriter stringWriter = new StringWriter();
PDFTextStripper stripper = new PDFTextStripper();
stripper.setLineSeparator("\n");
stripper.writeText(pdDoc, stringWriter);
text = stringWriter.toString();
stringWriter.close();
pdDoc.close();
}
catch (Exception e) {
_log.error(e.getMessage());
}
}
else if (fileExt.equals(".rtf")) {
try {
DefaultStyledDocument dsd = new DefaultStyledDocument();
RTFEditorKit rtfEditorKit = new RTFEditorKit();
rtfEditorKit.read(reader, dsd, 0);
text = dsd.getText(0, dsd.getLength());
}
catch (Exception e) {
_log.error(e.getMessage());
}
}
else if (fileExt.equals(".xls")) {
try {
XLSTextStripper stripper = new XLSTextStripper(fis);
text = stripper.getText();
}
catch (Exception e) {
_log.error(e.getMessage());
}
}