Created
July 26, 2019 04:17
-
-
Save erm3nda/b2beac710a47464d478d79ad336553c8 to your computer and use it in GitHub Desktop.
Convert source code files to single PDF with all code
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 | |
### 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