PdfReader reader = new PdfReader(source);
int pageCount = reader.getNumberOfPages();
StringBuilder builder = new StringBuilder();
for (int i = 1; i <= pageCount; i++) {
PdfTextExtractor extractor = new PdfTextExtractor(reader);
String pageText = extractor.getTextFromPage(i);
builder.append(pageText);
}
reader.close();
return builder.toString();
}