Last active
February 28, 2017 23:28
-
-
Save marcolussetti/9b9cf190490867658f495652829b60fc to your computer and use it in GitHub Desktop.
Print lots of source code files to pdf
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
# to ~/.bashrc | |
#src2pdf | |
src2pdf () { | |
local noext="${1%.*}" | |
pygmentize -O full -o "$noext.html" "$1" | |
# enabling line wrapping in <pre> blocks | |
perl -i -wpe '/<style.*>$/&&($_.="pre{white-space:pre-wrap;}\n")' "$noext.html" | |
wkhtmltopdf -s letter "$noext.html" "$noext.pdf" | |
rm "$noext.html" | |
} | |
#make all files into pdfs in the current dir | |
export -f src2pdf | |
find -exec bash -c 'src2pdf "$1"' - {} \; | |
mv *.pdf ~/Documents/comp3160-toprint/KamloopsCampusGuide/ | |
#merge pdf files | |
pdftk AndroidManifest.pdf MainActivity.pdf cat output ../KamloopsParkGuide.pdf | |
#a4 to letter | |
pdfjoin input.pdf --paper letterpaper --fitpaper false --outfile output.pdf |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment