8000 Improvements for handling configurations issues by zuphilip · Pull Request #40 · UB-Mannheim/zotero-ocr · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Improvements for handling configurations issues #40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions chrome/content/preferences.xul
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
</preferences>
<groupbox>
<caption label="OCR parameters"/>
<label value="You can indicate here the path to your OCR engine:"/>
<label value="Full location of the tesseract executable (when empty, some standard locations are searched for it):"/>
<textbox id="pref-zoteroocr-ocrPath-value" flex="1" preference="pref-zoteroocr-ocrPath"/>
<label value="You can indicate here the path to pdftoppm:"/>
<label value="Full location of the pdftoppm executable:"/>
<textbox id="pref-zoteroocr-pdftoppmPath-value" flex="1" preference="pref-zoteroocr-pdftoppmPath"/>
<hbox>
<label value="Choose a language/script you want to use for recognition (default is eng):"/>
Expand Down
15 changes: 13 additions & 2 deletions chrome/content/zoteroocr.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,21 @@ Zotero.OCR = new function() {
let ocrEngine = Zotero.Prefs.get("zoteroocr.ocrPath");
let found = false;
if (ocrEngine) {
let pathOrFile = FileUtils.File(ocrEngine);
// If a directory is given, then try for the standard name of the tool.
if (pathOrFile.isDirectory()) {
if (Zotero.isWin) {
ocrEngine = OS.Path.join(ocrEngine, "tesseract.exe");
}
else {
ocrEngine = OS.Path.join(ocrEngine, "tesseract");
}
Zotero.Prefs.set("zoteroocr.ocrPath", ocrEngine);
}
found = yield OS.File.exists(ocrEngine);
}
else {
let path = ["/usr/local/bin/", "/usr/bin/", "C:\\Program Files\\Tesseract-OCR\\", ""];
let path = ["", "/usr/local/bin/", "/usr/bin/", "C:\\Program Files\\Tesseract-OCR\\", "/opt/homebrew/bin/", "/usr/local/homebrew/bin/"];
for (ocrEngine of path) {
ocrEngine += "tesseract";
if (Zotero.isWin) {
Expand All @@ -49,7 +60,7 @@ Zotero.OCR = new function() {
}
}
if (!found) {
alert("No " + ocrEngine + " executable found.");
alert("Tesseract executable not found. Tried: " + ocrEngine);
return;
}

Expand Down
0