Converter PDF - Image


Converting pdf to image on Linux

# Syntax
# pdftoppm {input.pdf} {output.file} -png
# Example
pdftoppm Bulldog.pdf Bulldog.pdf -png
#  each page from the PDF file is converted to Bulldog.pdf-1.png, Bulldog.pdf-2.png
  • For a large number of pdf files
# Step 1 - PDF to IMAGE / PNG format #
for p in *.pdf
do 
   pdftoppm "$p" "$p" -png
done

Converting image to pdf on Linu

mkdir out
# convert
convert out-Bulldog.pdf-1.png Bulldog.pdf-2.png Bulldog.pdf-3.png out/final-Bulldog.pdf
# open 
xdg-open out/final-Bulldog.pdf
  • For a large number of images
# Step 2 - IMAGE / PNG to PDF format #
mkdir output
for i in *.pdf
do 
  b="$i"
  convert $b-?.png "output/$b" 
done

Compress files if needed

zip -r -e /tmp/Bulldog.pdf /tmp/output
  • -r : Recurse into directories
  • -e : Password protect our zip file
  • /tmp/project-invoices.pdf: Zip file name
  • /tmp/output: Path/folder name to zip and compress everything for ease of use

Ref


Bull Dog
Image source