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
1var result = "";
2
3// for each on all elements in div with id "grid"
4var elements = document.getElementById("grid").children;
5// get all children divs in div with id "grid"
6for (var i = 0; i < elements.length; i++) {
7 // get the current element
8 var element = elements[i];
9 // add the class "selected" to the current element
10 element.classList.add("selected");
11 // after that click on ocr button
12 document.querySelector(".pdf_ocr").click();
13 // wait 2 second
14 await new Promise(r => setTimeout(r, 2000));
15 // get div with class "modal"
16 var modal = document.querySelector("#spin_box");
17 // wait until modal class to be "modal" because it will be "modal show" and display: block
18 while (modal.classList.contains("show") && modal.style.display == "block") {
19 // wait 100ms
20 await new Promise(r => setTimeout(r, 1000));
21 }
22 // scroll to bottom of page
23 window.scrollTo(0, document.body.scrollHeight);
24 // get downloaded link
25 var link = document.querySelector(".dropdown-menu > #download_pdf_searchable");he link
26 // append the full href to result
27 result += link.href + "\n";
28 // remove the class "selected" from the current element
29 element.classList.remove("selected");
30 // scroll to top of page
31 window.scrollTo(0, 0);
32}
33
34function CopyToClipboard(copyText) {
35 navigator.clipboard
36 .writeText(copyText)
37 .then(() => {
38 console.log('copied to clipboard');
39 })
40 .catch(() => {
41 const input = document.createElement('input')
42 document.body.appendChild(input)
43 input.setAttribute('value', copyText)
44 input.select()
45 if (document.execCommand('copy')) {
46 document.execCommand('copy')
47 }
48 document.body.removeChild(input)
49 console.log('copied to clipboard2');
50 })
51}
52
53console.log(result);
54// copy the result to clipboard
55CopyToClipboard(result);