//get current urlpdf file url
URL url = new URL(driver.getCurrentUrl());
//create buffer reader object
BufferedInputStream fileToParse = new BufferedInputStream(url.openStream());
PDFParser pdfParser = new PDFParser(fileToParse);
pdfParser.parse();
//save pdf text into strong variable
String pdftxt = new PDFTextStripper().getText(pdfParser.getPDDocument());
//close PDFParser object
pdfParser.getPDDocument().close();
After applying above code, you can store all pdf file content into “pdftxt” string variable. Now you can verify string by giving in put. As if you want to verify “Selenium Or Webdiver” text. Use below code.
Assert.assertTrue(pdftxt.contains(“Selenium Or Webdiver”))
When run this code I get the error as Unable to open PDF Parser. Error: End-of-File, expected line.
I have followed on this issue a lot but dont see any solution to this issue. ANyone who has encountered this issue and resolved it. Appreciate you input