Compare commits
10 Commits
d6d75a5870
...
master
Author | SHA1 | Date | |
---|---|---|---|
89d8045655 | |||
c85430e1e6 | |||
5e773c2921 | |||
a38b9a987e | |||
ce5edfbef8 | |||
ce5a85dec4 | |||
54631a44cd | |||
7fc13491ce | |||
ccbb6246cd | |||
20ffba4084 |
59
README.md
59
README.md
@ -1,3 +1,62 @@
|
|||||||
# scantopdf
|
# scantopdf
|
||||||
|
|
||||||
A quick bash script that wraps around tesseract and allows tesseract to work on pdfs of scans
|
A quick bash script that wraps around tesseract and allows tesseract to work on pdfs of scans
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
To install this script, just paste these commands in the terminal
|
||||||
|
```
|
||||||
|
git clone https://git.karma-riuk.com/karma/scantopdf /tmp/scantopdf
|
||||||
|
sudo cp /tmp/scantopdf/scantopdf /usr/local/bin/scantopdf
|
||||||
|
sudo chmod 755 /usr/local/bin/scantopdf
|
||||||
|
```
|
||||||
|
|
||||||
|
Please verify that the path `/usr/local/bin` is in the global variable `$PATH`.
|
||||||
|
To verify this, issue the following command:
|
||||||
|
```bash
|
||||||
|
echo "$PATH" | grep "/usr/local/bin"
|
||||||
|
```
|
||||||
|
if there is a line of output, you are all good!
|
||||||
|
If there isn't, then issue the following command:
|
||||||
|
```bash
|
||||||
|
export PATH="/usr/local/bin:$PATH"
|
||||||
|
echo "export PATH=\"/usr/local/bin:\$PATH\"" | sudo tee -a /etc/profile
|
||||||
|
```
|
||||||
|
and everything should be okay.
|
||||||
|
|
||||||
|
### Ensure successful installation
|
||||||
|
|
||||||
|
To make sure the installation has been done correctly, the following command
|
||||||
|
```bash
|
||||||
|
which scantopdf
|
||||||
|
```
|
||||||
|
should have the following output
|
||||||
|
```bash
|
||||||
|
/usr/local/bin/scantopdf
|
||||||
|
```
|
||||||
|
if it doesn't, try to restart the installation from scratch.
|
||||||
|
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
To use this script, follow this steps
|
||||||
|
1. Open a terminal
|
||||||
|
2. Go the location of the file you want to "convert" with the following command
|
||||||
|
```bash
|
||||||
|
cd <path>
|
||||||
|
```
|
||||||
|
where `<path>` is the location of the **folder** where lies the file to convert.
|
||||||
|
3. Use the command `scantopdf` and give it, as an argument, the file you want to
|
||||||
|
convert.
|
||||||
|
If the file name contains **spaces**, surround it with **quotes** `"`
|
||||||
|
```bash
|
||||||
|
scantopdf "I Promessi Sposi.pdf"
|
||||||
|
```
|
||||||
|
Optionally you can give it the `-v` flag (before the name of the file), to make
|
||||||
|
the script verbose, so instead of doing its job without saying anything, it will
|
||||||
|
print each step that it's doing.
|
||||||
|
```bash
|
||||||
|
scantopdf -v "La Divina Commedia.pdf"
|
||||||
|
```
|
||||||
|
|
||||||
|
4. You can open the converted pdf with whatever application you want, its name
|
||||||
|
will be the same as the old one, but with " - EDITABLE" at the end.
|
||||||
|
11
scantopdf
11
scantopdf
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
TMP_DIR="`mktemp -d`"
|
TMP_DIR="`mktemp -d`"
|
||||||
@ -18,7 +18,7 @@ verbose () {
|
|||||||
pdf_to_jpg () {
|
pdf_to_jpg () {
|
||||||
verbose "Converting the scan '$1' to jpg"
|
verbose "Converting the scan '$1' to jpg"
|
||||||
|
|
||||||
convert -density 300 -quality 100 "$1" "$TMP_DIR/out.jpg"
|
convert -density 300 -quality 100 "$1" "$TMP_DIR/out-%05d.jpg"
|
||||||
}
|
}
|
||||||
|
|
||||||
tesseract_jpgs () {
|
tesseract_jpgs () {
|
||||||
@ -40,11 +40,14 @@ usage () {
|
|||||||
cat << EOF
|
cat << EOF
|
||||||
scantopdf - A quick bash script that wraps around tesseract to make book scans "editable"
|
scantopdf - A quick bash script that wraps around tesseract to make book scans "editable"
|
||||||
|
|
||||||
Usage: scantopdf [-v|--verbose] input.pdf
|
Usage: scantopdf [-v|--verbose] file.pdf
|
||||||
|
scantopdf [-v|--verbose] "file with spaces.pdf"
|
||||||
scantopdf [-h|-?|--help]
|
scantopdf [-h|-?|--help]
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
input.pdf the file you want to make editable
|
file.pdf the file you want to make editable (make
|
||||||
|
sure to put quotes " around the file
|
||||||
|
name if the filename has spaces)
|
||||||
|
|
||||||
Optional arguments:
|
Optional arguments:
|
||||||
-v, --verbose print each step the script passes through
|
-v, --verbose print each step the script passes through
|
||||||
|
Reference in New Issue
Block a user