Skip to content

Instantly share code, notes, and snippets.

@aboueleyes
Created April 25, 2021 22:58
Show Gist options
  • Save aboueleyes/7cb45376cea32b64ac4e3b1ba4c147ec to your computer and use it in GitHub Desktop.
Save aboueleyes/7cb45376cea32b64ac4e3b1ba4c147ec to your computer and use it in GitHub Desktop.
Generate PDF files
#!/usr/bin/env python3
import os
file_name = 'template.tex'
with open(file_name, "w") as file_object:
file_object.write('\documentclass{beamer}\n')
file_object.write('\\usetheme{focus}\n')
file_object.write('\\begin{document}\n')
images = os.listdir('img')
text = []
for image in images:
silde_text = '''
\\begin{frame}{%s}
\\begin{center}
\includegraphics[width=311px,height=200pt]{"img/%s"}
\end{center}
\end{frame}
''' % (image.rsplit('.',1)[0], image)
text.append(silde_text)
with open(file_name, "a") as file_object:
for item in text:
file_object.write(item)
with open(file_name, "a") as file_object:
file_object.write(''''
\\begin{frame}[focus]
Any Questions?
\end{frame}
\\begin{frame}[focus]
Thank You.
\end{frame}
\end{document}
''')
os.system(f'pdflatex {file_name}')
os.system(f'zathura {file_name.rsplit(".",1)[0]}.pdf & ')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment