public String getText(final InputStream source) throws IOException {
Assert.notNull(source, "source");
PdfReader reader = new PdfReader(source);
PdfReaderContentParser parser = new PdfReaderContentParser(reader);
TextExtractionStrategy strategy = new SimpleTextExtractionStrategy();
int pageCount = reader.getNumberOfPages();
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
PrintWriter writer = new PrintWriter(outputStream);
for (int i = 1; i <= pageCount; i++) {
TextExtractionStrategy result = parser.processContent(i, strategy);
String pageText = result.getResultantText();
writer.println(pageText);
}
reader.close();
writer.close();