Skip to content

Instantly share code, notes, and snippets.

@arvati
Created November 26, 2023 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arvati/3d50e337b4feb78e983d688c1ab29525 to your computer and use it in GitHub Desktop.
Save arvati/3d50e337b4feb78e983d688c1ab29525 to your computer and use it in GitHub Desktop.
PDF to TEXT OCR online

site: https://www.newocr.com/

step 1 = only one time

$('#page').val("1");$('#form-ocr').submit();$('#ocr').click();

step 2 = 343 times

localStorage.setItem($('#page option:selected').text(),$('#result2-container').contents().find('pre').text());$('#page').val(String(parseInt($('#page option:selected').text(), 10) + 1));$('#form-ocr').submit();$('#ocr').click();

step 3 = save string

var data = ""; for (let i = 1; i <= 343; i++) { data = data + "\n" + localStorage.getItem(String(i));}

step 4 = download file

var blob = new Blob([data], {type: 'text/plain'}), e = document.createEvent('MouseEvents'), a = document.createElement('a');
a.download = 'arquivo.txt'; a.href = window.URL.createObjectURL(blob); a.dataset.downloadurl =  ['text/plain', a.download, a.href].join(':');
e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); a.dispatchEvent(e)
@arvati
Copy link
Author

arvati commented Nov 26, 2023

$('#page').val("22");
// $('#form-ocr').submit();
$('#ocr').click();
$('#result2-container').contents().find('pre').text()

$('#page option:selected').text();

$('#page').val("1");
function next_page() {
	$('#page').val(String(parseInt($('#page option:selected').text(), 10) + 1));
	$('#form-ocr').submit();
	$('#ocr').click();
	localStorage.setItem($('#page option:selected').text(),$('#result2-container').contents().find('pre').text());
	return localStorage.getItem($('#page option:selected').text())
}
next_page()

$('#page').val("1");for (let i = 1; i <= 343; i++){next_page();};


	return $('#result2-container').contents().find('pre').text()
	
function all_pages() {
	for (let i = 1; i <= 343; i++) {
		$('#page').val(String(i));
		$('#form-ocr').submit();
		$('#ocr').click();
		localStorage.setItem(String(i),$('#result2-container').contents().find('pre').text());
	}
}

all_pages()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment