Skip to content

Commit 27a71c9

Browse files
committed
program pdf fixes
1 parent 4aa2427 commit 27a71c9

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

scripts/make_program_pdf.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
content = line.split(': ')[0]
2727
print(f'Trying "{content}" ({i})')
2828
if exists(f'../speeches/{content}.md'):
29-
run(['pandoc', ('../speeches/%s.md' % content), '-V', 'geometry:papersize={ 6in, 10.3in }', '-V', 'geometry:margin=0.5in', '-o', f'{outd}/{i}.pdf'], check=True)
29+
run(['pandoc', ('../speeches/%s.md' % content), '-V', 'geometry:papersize={ 8.5in, 14in }', '-V', 'geometry:margin=0.5in', '-V', 'fontsize=17pt','-V', 'documentclass=extarticle', '-o', f'{outd}/{i}.pdf'], check=True)
3030
continue
3131
g=glob(f'../songs/{content}/*-chord-chart.pdf')
3232
if g:
@@ -45,7 +45,15 @@
4545
if fn.endswith('.pdf'):
4646
run(['cp', fn, f'{outd}/{i}.pdf'], check=True)
4747
found=True
48-
elif fn.endswith('.html') or fn.endswith('.txt') :
48+
elif fn.endswith('.txt') :
49+
thtmlfn = f'{outd}/{i}.html'
50+
with open(thtmlfn,'w') as thtmlf:
51+
thtmlf.write('<html><head><style> @page { size:legal } body { font-size: 14pt; } </style></head><body><pre>')
52+
thtmlf.write(open(fn).read())
53+
thtmlf.write('</pre></body></html>')
54+
run(['google-chrome', '--headless', '--disable-gpu', f'--print-to-pdf={outd}/{i}.pdf', thtmlfn], check=True)
55+
found=True
56+
elif fn.endswith('.html'):
4957
run(['google-chrome', '--headless', '--disable-gpu', f'--print-to-pdf={outd}/{i}.pdf', fn], check=True)
5058
found=True
5159
else:
@@ -55,7 +63,7 @@
5563
break
5664
else:
5765
print(f'WARNING: skipping {content}')
58-
66+
5967
run(['gs', '-dNOPAUSE', '-sDEVICE=pdfwrite', f'-sOUTPUTFILE={sys.argv[1]}.pdf', '-dBATCH'] + [ f'{outd}/{j}.pdf' for j in range(1,i+1) ], check=True)
6068
print(outd)
6169
remove(cssfn)

0 commit comments

Comments
 (0)