I'm using POI to get text contents and having intermittent freezing. The java
thread calling this part hangs sometimes.
Have you experience similar problems? I'm using following code.
PDFParser parser;
String parsedText = null;
PDFTextStripper pdfStripper = null;
PDDocument pdDoc = null;
COSDocument cosDoc = null;
try {
parser = new PDFParser(in);
parser.parse();
cosDoc = parser.getDocument();
pdfStripper = new PDFTextStripper();
pdDoc = new PDDocument(cosDoc);
if(!pdDoc.isEncrypted()){
pdfStripper.setStartPage(1);
pdfStripper.setEndPage(Integer.MAX_VALUE);
parsedText = pdfStripper.getText(pdDoc);
}else{
log.error("PDF Failed (" + fname+ ") Encrypted");
}
} catch (Exception e) {
log.error("PDF Failed (" + fname + ") Error: " +
e.getMessage());
} finally {
try {
if (cosDoc != null){
cosDoc.close();
}
if (pdDoc != null){
pdDoc.close();
}
} catch (Exception e) {
log.error("PDF Close (" + fname + ") Error: " +
e.getMessage());
}
}