Skip to content

Instantly share code, notes, and snippets.

@originalsouth
Last active July 21, 2017 15:00
Show Gist options
  • Save originalsouth/52b80112ed01f54bdfed130d35866394 to your computer and use it in GitHub Desktop.
Save originalsouth/52b80112ed01f54bdfed130d35866394 to your computer and use it in GitHub Desktop.
Outline pdf images with type 3 fonts
#!/usr/bin/env zsh
if [[ $# -eq 0 ]]
then
echo 'outline_type3.zsh [option/files]'
echo 'options:'
echo "\t-f\ttoggle overwrite"
else
overwite=false
for file in "$@"
do
if [[ "$file" == "-f" ]]
then
overwrite=!$overwite
elif [[ $(head -c 4 "$file") = "%PDF" && $(pdffonts $file | grep 'Type 3' | wc -l) -gt 0 ]]
then
echo "converting $file"
output="$(dirname $file)/outlined-${file##*/}"
gs -q -o $output -dNoOutputFonts -sDEVICE=pdfwrite $file
if [ $overwrite ]
then
mv -f $output $file
fi
fi
done
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment