#!/bin/sh # Quick and Dirty PDF Sharing # Converts a PDF to PNGs (using Image Magick) # and spits out HTML+JS to browse them. # By John Resig (ejohn.org) # Distributed under the MIT License # Input: # ./pdfshare.sh some.pdf # Output: # some/*.png (PDF Images) # some.html (HTML snippet) # some.zip (Zip file of Images + PDF) # Change this line to match your final upload destination PREFIX="http://ejohn.org/files/" # Leave the rest alone PDF=$1 PDFPATH=`echo "${PDF}"|sed s/[^\\\/]*$//` PDFNAME=`echo "${PDF}"|sed s/.pdf$//|sed s/^.*\\\///` PNGDIR=${PDFPATH}${PDFNAME} mkdir -p ${PNGDIR} rm -f ${PNGDIR}/*.png rm -f ${PNGDIR}.zip convert -resize 400x400 ${PDF} ${PNGDIR}/%03d.png &> /dev/null zip -r ${PNGDIR}.zip ${PNGDIR} ${PDF} &> /dev/null NUM=`ls -la ${PNGDIR}/*.png | wc -l` echo "

Download PDF
"\ "" > ${PNGDIR}.html