Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
makeabstracts.py
#!/usr/local/bin/python3
# Michael Yoshitaka Erlewine 2016, public domain
# instructions:
# brew install enscript
# Install PDFtk
# current build: https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/pdftk_server-2.02-mac_osx-10.11-setup.pkg
#
# setup csv with EasyChair ID, desired filename, authors
import csv, sys, os
PREFIX = 'easychair/GLOW_in_Asia_2017_abstract_'
NEWPREFIX = 'abstracts/'
CONFERENCE = 'GLOW in Asia XI, February 2017'
f = open(sys.argv[1], 'rU')
try:
reader = csv.reader(f, dialect='excel')
for row in reader:
input = PREFIX + row[0] + '.pdf'
output = NEWPREFIX + row[1] + '.pdf'
# reference: http://www.commandlinefu.com/commands/view/9984/stamp-a-text-line-on-top-of-the-pdf-pages.
bash = 'echo "{}. {}" | enscript -B -f Helvetica12 -o- | ps2pdf - | pdftk {} stamp - output {}'.format(row[2], CONFERENCE, input, output)
print(bash)
os.system(bash)
finally:
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment