Created
November 25, 2013 15:25
-
-
Save piotrplenik/7642967 to your computer and use it in GitHub Desktop.
Create flatten PDF file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Script to convert PDF - create flatten PDF file | |
# | |
# Format: | |
# ./convert input-file.pdf output-file.pdf | |
# | |
# Dependencies: | |
# * pdftk | |
# * imagemagick | |
PDF=$1 | |
OUT_PDF=$2 | |
DENSITY=300 | |
echo "Processing $PDF" | |
DIR=`basename "$1" .pdf` | |
echo ' Converting pages to JPEG files...' | |
pdftocairo -r $DENSITY -jpeg $PDF /tmp/convert-"$DIR" | |
echo ' Merge JPEG files into one PDF' | |
convert -density $DENSITY /tmp/convert-"$DIR"* $OUT_PDF | |
rm /tmp/convert-"$DIR"* | |
echo 'All done' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment