Skip to content

Instantly share code, notes, and snippets.

@erm3nda
Created July 26, 2019 04:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erm3nda/b2beac710a47464d478d79ad336553c8 to your computer and use it in GitHub Desktop.
Save erm3nda/b2beac710a47464d478d79ad336553c8 to your computer and use it in GitHub Desktop.
Convert source code files to single PDF with all code
#!/bin/bash
### this script needs:
### python module pygmentize, wkhtmltopdf and ghostscript
### works for any source code, just modify -l python, and any .py reference to your choice
# Change this to the repository directory
REPOSITORY=$1
# Iterate over the repository
while read source_file
do
filename=$(basename $source_file)
dir=$(dirname $source_file)
# For each .lua file found, generate an HTML file in /tmp
pygmentize -l python -f html -O full,style=vim $source_file > /tmp/${filename}.html
# Convert the HTML file to a PDF file in the same directory
# as the .py file
wkhtmltopdf /tmp/${filename}.html $1/${filename}.pdf
done < <(find $REPOSITORY -type f -iname '*.py')
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=./resume.pdf *.py.pdf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment