Skip to content

Instantly share code, notes, and snippets.

@barryrowlingson
Created December 2, 2014 18:17
Show Gist options
  • Save barryrowlingson/8e01274f12df1c5986b6 to your computer and use it in GitHub Desktop.
Save barryrowlingson/8e01274f12df1c5986b6 to your computer and use it in GitHub Desktop.
Convert PDF to images in a word doc
#!/bin/bash
mkdir -p pages
rm pages/image*png
convert -verbose -colorspace RGB -units PixelsPerInch -resize 1024 -geometry 1224 -interlace none -density 200 -quality 80 $1 pages/image.png
npages=`ls pages/image-*.png| wc -l`
for (( i=0 ; i<$npages ; i++ ))
do
echo '![](pages/image-'$i'.png)'
echo " "
echo 'Notes:'
echo " "
done > doc.md
pandoc -f markdown -t docx doc.md -o doc.docx
@barryrowlingson
Copy link
Author

Students want to annotate your lovely beamer PDF slide presentation, but Adobe PDF annotations aren't quiet their bag. They usually get powerpoint slides from lecturers and then scrawl under them.

Solution here is to convert to a word doc. I might do another solution that converts to an LibreOffice Impress XML document so they can scrawl in the notes space. Or teach them all LaTeX... Anyway...

From a folder with a .pdf in it, this creates a 'pages' folder, cleans it out, then uses imagemagick convert to create an image per page. Then loop over the number of pages and create a markdown doc with an image include and a 'notes' text. Then use pandoc to process that markdown into a Word (spit) doc. That can then be opened and students can annotate your slides with free text between the images.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment