public static String convertPDFDocument(String url) throws FileNotFoundException, IOException { PDFTextStripper stripper = new PDFTextStripper(); PDFParser parser = new PDFParser(new FileInputStream(url)); parser.parse(); PDDocument doc = parser.getPDDocument(); String text = stripper.getText(doc); parser.clearResources(); doc.close(); if(text==null || text.isEmpty() || verifyValidOCRlenght(text)==false) { try { text = fileOCR(url); } catch (TesseractException e) { text = new String(); } } if(text==null || text.isEmpty() || verifyValidOCRlenght(text)==false) { try { text = convertEncryptedPDFDocument(url); } catch (TesseractException e) { text = new String(); } } return NormalizationForm.removeOffsetProblemSituation(text); }