-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpdfgen
More file actions
executable file
·41 lines (35 loc) · 932 Bytes
/
pdfgen
File metadata and controls
executable file
·41 lines (35 loc) · 932 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python
from tempfile import mkstemp, mkdtemp
from shutil import rmtree, move
import sys
import os
from subprocess import call
filename = sys.argv[1]
if not filename.endswith(".tex"):
filename += ".tex"
f = open(filename, "w")
try:
f.write(
r'''
\documentclass[a4paper]{minimal}
\usepackage[margin=0.5in,landscape]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage{grffile}
\usepackage[pdftex]{graphicx}
\usepackage{moresize}
\begin{document}
''')
for i in sys.argv[2:]:
b = os.path.splitext(os.path.basename(i))[0]
d = os.path.dirname(i)
f.write(r'\centering {\HUGE\verb+%s+} \newline\includegraphics[width=\textwidth,height=0.9\textheight,keepaspectratio]{%s}\newline\verb+%s+\newpage'%(b, i, d))
f.write("\n")
f.write(
r"""
\end{document}
""")
f.close()
call(['pdflatex', '-interaction=batchmode', '-halt-on-error', '-shell-escape', filename])
finally:
pass