ich möchte gerne PDF-Dateien zu Text-Dateien wandeln.
Dazu nutze ich schon länger das python tool pdf2txt (pdfminer.six aus python3-pdfminer), was bei PDFs, welche durchsuchbaren Text enthalten, auch wunderbar funktioniert. Allerdings habe ich auch immer mal PDFs, wo die Seiten als Image enthalten sind. Diese müssten per OCR konvertiert werden. Jetzt habe ich zwar schon ein älteres Tool gefunden, dass das im Prinzip können soll, doch ich bekomme es einfach nicht zum Laufen unter Bookworm: https://github.com/annacprice/pdf-scraper
Dieses kleine Python-Script soll zuerst mit oben genannten Tool (pdfminer.six) versuchen den Text zu bekommen. Bekommt es damit nichts zurück, soll es mit tesseract OCR nutzen. Leider bekomme ich das tool nicht zum Laufen. Ihm fehlt offenbar das pytesseract Modul:
Code: Alles auswählen
Traceback (most recent call last):
File "/tmp/pdff/./pdfscraper.py", line 9, in <module>
import pytesseract
ModuleNotFoundError: No module named 'pytesseract'
Code: Alles auswählen
pipx install pdfscraper --include-deps
⚠️ Note: chardetect was already on your PATH at /usr/local/bin/chardetect
⚠️ Note: f2py was already on your PATH at /usr/bin/f2py
⚠️ Note: normalizer was already on your PATH at /usr/bin/normalizer
⚠️ File exists at /home/user/.local/bin/tabulate and points to
/home/user/.local/bin/tabulate, not
/home/user/.local/pipx/venvs/pdfscraper/bin/tabulate. Not modifying.
⚠️ File exists at /home/user/.local/bin/pytesseract and points to
/home/user/.local/pipx/venvs/pytesseract/bin/pytesseract, not
/home/user/.local/pipx/venvs/pdfscraper/bin/pytesseract. Not modifying.
installed package pdfscraper 1.1.9, installed using Python 3.11.2
These apps are now globally available
- camelot
- chardetect
- distro
- dumppdf.py
- f2py
- imageio_download_bin
- imageio_remove_bin
- lsm2bin
- normalizer
- pdf2txt.py
- tiff2fsspec
- tiffcomment
- tifffile
- pytesseract (symlink missing or pointing to unexpected location)
- tabulate (symlink missing or pointing to unexpected location)
done! ✨ 🌟 ✨
Ich kenne mich leider nicht tief genug mit python aus, um das ans Laufen zu bringen. Kennt jemand ein anderes Tool, welches genau das macht und von der Kommandozeile (wegen Stapelverarbeitung) aus nutzbar ist?
Nachtrag: Ich habe gerade selber festgestellt, dass das pdfscraper tool von PIP(x) (ebenso pdf-scraper) mit dem oben verlinkten pdf-scraper nichts zu tun hat.
Danke im Voraus