Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/LeoFCardoso/pdf2pdfocr

A free tool to OCR a PDF and add a text "layer" in the original file, making a searchable PDF. Use only open source tools. Please tip!
https://github.com/LeoFCardoso/pdf2pdfocr

docker ocr pdf pdftk python tesseract

Last synced: 2 months ago
JSON representation

A free tool to OCR a PDF and add a text "layer" in the original file, making a searchable PDF. Use only open source tools. Please tip!

Lists

README

        

# pdf2pdfocr
A tool to OCR a PDF (or supported images) and add a text "layer" (a "pdf sandwich") in the original file making it a searchable PDF.
The script uses only open source tools.

# donations
This software is free, but if you like it, please donate to support new features.

[![paypal](https://www.paypalobjects.com/en_US/GB/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=PZZU5APJGSWVA&lc=GB&item_name=pdf2pdfocr%20development&currency_code=USD)

Bitcoin (BTC) address: [173D1zQQyzvCCCek9b1SpDvh7JikBEdtRJ](https://blockchair.com/bitcoin/address/173D1zQQyzvCCCek9b1SpDvh7JikBEdtRJ)

# tips
Tips are also welcome!

[![tippin.me](https://badgen.net/badge/%E2%9A%A1%EF%B8%8Ftippin.me/@LeoFCardoso/F0918E)](https://tippin.me/@LeoFCardoso)

Dogecoin (DOGE) address: [D94hD2qPnkxmZk8qa1b6F1d7NfUrPkmcrG](https://blockchair.com/dogecoin/address/D94hD2qPnkxmZk8qa1b6F1d7NfUrPkmcrG)

PIX (Brazilian Instant Payments): 0726e8f2-7e59-488a-8abb-bda8f0d7d9ce

[![chave PIX](https://raw.githubusercontent.com/LeoFCardoso/pdf2pdfocr/master/pix_qrcode.png)](https://nubank.com.br/pagar/414xb/ndt4lfy9GT)

Please contact for donations and tips in other cryptocurrencies.

# installation
In Linux, installation is straightforward. Just install required packages and be happy.
You can use "install_command" script to copy required files to "/usr/local/bin".

In macOS, you will need macports.

# First install Xcode from Mac App Store, then:
xcode-select --install
sudo xcodebuild -license
# Install Macports from https://www.macports.org/install.php
sudo port selfupdate
# Install tesseract as main ocr engine (Portuguese included below - please add your preferred languages)
sudo port install git libtool automake autoconf tesseract tesseract-por tesseract-osd tesseract-eng
# Install cuneiform (the optional ocr engine - see flag "-c")
sudo port install cuneiform
# Install qpdf (optional for better performance)
sudo port install qpdf
# Install python 3 and other dependencies
sudo port install python39 py39-pip poppler poppler-data ImageMagick ghostscript
# Configure default python3 installer
sudo port select --set python python39
sudo port select --set python3 python39
sudo port select --set pip pip39
sudo port select --set pip3 pip39
# Configure venv and python deps in fixed home directory
python3 -m venv ~/pdf2pdfocr-venv
~/pdf2pdfocr-venv/bin/python3 -m pip install --upgrade pip
~/pdf2pdfocr-venv/bin/pip3 install --upgrade setuptools
~/pdf2pdfocr-venv/bin/pip3 install -r requirements.txt
~/pdf2pdfocr-venv/bin/pip3 install -r requirements_gui.txt
# Copy main scripts to venv
cp pdf2pdfocr.py pdf2pdfocr_gui.py pdf2pdfocr_multibackground.py ~/pdf2pdfocr-venv/bin
sudo ./install_command

Cuneiform and qpdf are optional.

In Windows, you will need to manually install required software. Please read "install_windows.txt" file and try the tutorial with scoop tool. It's easy! :-)

# docker (without GUI)
The Dockerfile can be used to build a docker image to run pdf2pdfocr inside a container. To build the image, please download all sources and run.

docker build -t leofcardoso/pdf2pdfocr:latest .
It's also possible to pull the docker image from docker hub.

docker pull leofcardoso/pdf2pdfocr
You can run the application with docker run.

docker run --rm -v "$(pwd):/home/docker" leofcardoso/pdf2pdfocr -v -i ./sample_file.pdf
# basic usage
This will create a searchable (OCR) PDF file in the same dir of "input_file".

pdf2pdfocr.py -i
In some cases, you will want to deal with option flags. Please use:

pdf2pdfocr.py --help
to view all the options.

It's also possible to use GUI.

pdf2pdfocr_gui.py <>

# fun
Caseiro com orgulho! ;-)