Skip to content

Instantly share code, notes, and snippets.

@irgendwr
Last active November 18, 2020 19:32
Show Gist options
  • Save irgendwr/3ad324be7152276d464970bdc82561bf to your computer and use it in GitHub Desktop.
Save irgendwr/3ad324be7152276d464970bdc82561bf to your computer and use it in GitHub Desktop.
Converts multiple SVGs to a single PDF and applies OCR
#!/usr/bin/env bash
# Requires rsvg-convert, pdfunite and ocrmypdf
echo "This script will convert all *.svg files in the current directory to *.pdf files and merge them into a single PDF file called all.pdf and then apply OCR to create all_ocr.pdf. Existing files with the same names will be overwritten."
read -p "Do you want to proceed? [Y/n] " -n 1 -r
echo
if [[ $REPLY =~ ^([Yy]| ) ]] || [[ -z $REPLY ]]; then
# Convert all svg files to pdf files
for i in *.svg; do
rsvg-convert -f pdf -o ${i%.*}.pdf $i
done
# merge all pdf files into all.pdf
pdfunite *.pdf all.pdf
# apply ocr, export as all_ocr.pdf
ocrmypdf all.pdf all_ocr.pdf
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment