1
0
mirror of https://github.com/kmein/niveum synced 2026-03-19 11:31:09 +01:00

feat: 256color + countdown + pdf-ocr.sh

This commit is contained in:
2021-05-02 18:56:38 +02:00
parent 4f962778b7
commit 3a21680812
3 changed files with 74 additions and 0 deletions

23
.bin/pdf-ocr.sh Executable file
View File

@@ -0,0 +1,23 @@
#!/usr/bin/env nix-shell
#! nix-shell -i bash -p poppler_utils tesseract4
set -eu
pdf_path="$(realpath "$1")"
[ -f "$pdf_path" ] || {
echo "Usage: $0 FILE.pdf" >&2
exit 1
}
tmpdir="$(mktemp -d)"
trap 'rm -rf $tmpdir' EXIT
cd "$tmpdir"
pdftoppm -png "$pdf_path" pdf-ocr
for png in pdf-ocr*.png; do
tesseract "$png" "$png.txt" 2>/dev/null
done
cat pdf-ocr-*.txt