i2pdf is a free service for OCR Arabic text. The idea of this website is to convert pdf to images and uploaded them to google docs for processing because google has the best OCR engine that supports many languages. the problem in i2pdf is supported one image at a time by a select image that you want to convert and press on button OCR to process.
this script automates that instead of you processing all images and at the end the result with copy to the clipboard. just paste on notepad and use any download software to download these pdfs also use any software for pdf like adobe or Foxit to merge them in one file.
Steps:
- Go to https://www.i2pdf.com/pdf-ocr/arabic and upload your pdf
- press
CTRL + Shift + i
to open Chrome Dev tools - In Console Paste Script
var result = "";
// for each on all elements in div with id "grid"
var elements = document.getElementById("grid").children;
// get all children divs in div with id "grid"
for (var i = 0; i < elements.length; i++) {
// get the current element
var element = elements[i];
// add the class "selected" to the current element
element.classList.add("selected");
// after that click on ocr button
document.querySelector(".pdf_ocr").click();
// wait 2 second
await new Promise(r => setTimeout(r, 2000));
// get div with class "modal"
var modal = document.querySelector("#spin_box");
// wait until modal class to be "modal" because it will be "modal show" and display: block
while (modal.classList.contains("show") && modal.style.display == "block") {
// wait 100ms
await new Promise(r => setTimeout(r, 1000));
}
// scroll to bottom of page
window.scrollTo(0, document.body.scrollHeight);
// get downloaded link
var link = document.querySelector(".dropdown-menu > #download_pdf_searchable");he link
// append the full href to result
result += link.href + "\n";
// remove the class "selected" from the current element
element.classList.remove("selected");
// scroll to top of page
window.scrollTo(0, 0);
}
function CopyToClipboard(copyText) {
navigator.clipboard
.writeText(copyText)
.then(() => {
console.log('copied to clipboard');
})
.catch(() => {
const input = document.createElement('input')
document.body.appendChild(input)
input.setAttribute('value', copyText)
input.select()
if (document.execCommand('copy')) {
document.execCommand('copy')
}
document.body.removeChild(input)
console.log('copied to clipboard2');
})
}
console.log(result);
// copy the result to clipboard
CopyToClipboard(result);