Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. PDFParser parser = null;
  2. PDDocument pdDoc = null;
  3. COSDocument cosDoc = null;
  4. PDFTextStripper pdfStripper;
  5.  
  6. String parsedText = "";
  7. String fileName = "Audit.pdf";
  8. File file = new File(fileName);
  9. try {
  10. parser = new PDFParser(new RandomAccessFile(file, "r"));
  11. parser.parse();
  12. cosDoc = parser.getDocument();
  13. pdfStripper = new PDFTextStripper();
  14. pdDoc = new PDDocument(cosDoc);
  15. parsedText = pdfStripper.getText(pdDoc);
  16. //System.out.println(parsedText);
  17. } catch (Exception e) {
  18. e.printStackTrace();
  19. try {
  20. if (cosDoc != null)
  21. cosDoc.close();
  22. if (pdDoc != null)
  23. pdDoc.close();
  24. } catch (Exception e1) {
  25. e1.printStackTrace();
  26. }
  27. }
  28.  
  29. System.out.println(parsedText);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement