Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- PDFParser parser = null;
- PDDocument pdDoc = null;
- COSDocument cosDoc = null;
- PDFTextStripper pdfStripper;
- String parsedText = "";
- String fileName = "Audit.pdf";
- File file = new File(fileName);
- try {
- parser = new PDFParser(new RandomAccessFile(file, "r"));
- parser.parse();
- cosDoc = parser.getDocument();
- pdfStripper = new PDFTextStripper();
- pdDoc = new PDDocument(cosDoc);
- parsedText = pdfStripper.getText(pdDoc);
- //System.out.println(parsedText);
- } catch (Exception e) {
- e.printStackTrace();
- try {
- if (cosDoc != null)
- cosDoc.close();
- if (pdDoc != null)
- pdDoc.close();
- } catch (Exception e1) {
- e1.printStackTrace();
- }
- }
- System.out.println(parsedText);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement