GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - jfilter/pdf-scripts: 📑 Scripts to repair, verify, OCR, compress, wrangle, crop (etc.) PDFs

BranchesTags
Open more actions menu

Latest commit

 

History

47 Commits
47 Commits

Folders and files

NameName
Last commit message
Last commit date
crop
crop
 
 
sort_by
sort_by
 
 
utils
utils
 
 
wrangle_pdf
wrangle_pdf
 
 
.editorconfig
.editorconfig
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
clean_metadata_pdf.sh
clean_metadata_pdf.sh
 
 
compress_pdf.sh
compress_pdf.sh
 
 
is_ocrd_pdf.sh
is_ocrd_pdf.sh
 
 
ocr_pdf.sh
ocr_pdf.sh
 
 
pipeline.sh
pipeline.sh
 
 
poetry.lock
poetry.lock
 
 
pyproject.toml
pyproject.toml
 
 
reduce_size_pdf.sh
reduce_size_pdf.sh
 
 
repair_pdf.sh
repair_pdf.sh
 
 
setup.sh
setup.sh
 
 
verify_pdf.sh
verify_pdf.sh
 
 

Repository files navigation

PDF Scripts

Scripts (mostly Bash) to repair, verify, OCR, compress (etc.) PDFs.

Currently in beta status, so except backward-incompatible changes.

Install

You need to have Bash installed.

The scripts use several software libraries. setup.sh installs them for macOS (via brew) or Ubuntu/Debian.

Usage

  1. Go to root of this repository: cd pdf-scripts
  2. Excute script ./pipeline.sh -l deu /path/to/document-in-german.pdf

Please refer to the scripts for the command-line arguments and options. NB: It's not possible to combine options, e.g., use -x -y instead of -xy.

Most scripts work on individual PDFs as well as on folders full of PDFs.

Overview

ocr_pdf.sh

OCR PDFs with OCRmyPDF.

repair_pdf.sh

Using: pdftocairo from poppler, mutool clean from MuPDF, qpdf

Caveat: May remove text in OCRd PDFs. Use --check to check for OCRd text in order to preserve it.

verify_pdf.sh

Checks if text can be extracted (if it's already on the PDF)

compress_pdf.sh

Using ghostcript to compress images in PDFs.

reduce_size_pdf.sh

Use compress_pdf.sh but also pdfsizeopt to reduze file size of PDFs.

clean_metadata_pdf.sh

Remove metadata with exiftool.

is_ocrd_pdf.sh

Detect OCRd PDFs. See also sort_ocrd_pdfs.sh to sort PDFs.

pipeline.sh

Combining several of the above scripts.

FAQ

Why Bash?

Bash is still the most-used shell. And the scipts comprise mostly of simple conditionals and sequences of CLI commands. This could also be done with Python's psutil but this would add yet another layer. However, at some point, I most probable port the scripts to simple POSIX-Shell.

Related Work

  • https://github.com/NicolasBernaerts/ubuntu-scripts/blob/master/pdf/
  • more tools for PDF processing in my blog post
  • https://github.com/baltpeter/scanprep

Development

  • focus on Bash v4+
  • write Python 3.6+ scripts if Bash gets too complicated
  • use Docker images if available
  • should run on the major Unix-like OSs (Linux (e.g. Ubuntu), macOS)
  • format code with shfmt, e.g., extension for VS Code
  • lint scripts with shellcheck, e.g., extension for VS Code

Common Commands

Concat PDFs into one PDF

qpdf --empty --pages *.pdf -- out.pdf

Images to PDF

convert *.jpg pictures.pdf

Rotate PDFs

qpdf in.pdf  out.pdf --rotate=+90

License

GPLv3.

About

📑 Scripts to repair, verify, OCR, compress, wrangle, crop (etc.) PDFs

Topics

bashbash-scriptcompresscrop-imageocrpdfpythonrepairverify

Resources

Readme
GPL-3.0 license
Activity

Stars

73 stars

Watchers

1 watching

Forks

4 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.