pdfbox-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeffrey Zhao <jz...@rivit.ca>
Subject RE: POI freezing?
Date Wed, 08 Feb 2012 14:10:10 GMT
Sorry, wrong code. It's following code for the POI.

	String txt = "";
		POITextExtractor txtExtractor = null;
				
		try{
			txtExtractor = ExtractorFactory.createExtractor(in);
			txt = txtExtractor.getText();
			txt = txt.trim();
			txtExtractor = null;
			//poiFactory = null;
		}catch(Exception e){
			log.error(e.getMessage(),e);			
		}
		
		txt = txt.trim();
						
		return txt;


-----Original Message-----
From: Jeffrey Zhao [mailto:jzhao@rivit.ca] 
Sent: February 8, 2012 8:56 AM
To: users@pdfbox.apache.org
Subject: POI freezing?

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());
                  }
            }


Mime
View raw message