In this blog, we will learn how we can fetch data from images and PDFs.
This Blog Contains:
- Read Text From Image Using OCR with Tesseract (tess4j)
- Reading PDF Text Using PDFUtil
- Save PDF as Image Using PDFUtil
- Extract Images From PDF Using PDFUtil
Fetch Text From Image In Selenium
To get a text from the Image in selenium, we use Optical Character Recognition (OCR) with Tesseract (tess4j). Tesseract Supports UTF-8 Unicode.
- First, we need to create a folder with the name “tesseract” in our project and put trained data in that folder. You can find trained data for any language from the below URL:
https://github.com/tesseract-ocr/tessdata
Just Download eng. trained data for English Language and put it into Tesseract Folder for your project.
- Add below is maven dependency for tesseract (tess4j):
- Below is the Java code to fetch text from the image:
Read Also:- Process Java Script Executor in Selenium Test Automation
Fetch Text From PDF
- Add Below Maven Dependency For PDFUtil
- Below Java Code is used to Read Text From PDF
- Below Java Code is used to Save PDF as an Image
- Below Java Code is used to Fetch Image From PDF
Original Source:-https://www.devstringx.com/using-selenium-java
No comments:
Post a Comment