| import tempfile |
| import subprocess |
| import os |
| import shutil |
|
|
|
|
| def render_latex(latex_command, latex_data): |
| src_path = os.path.dirname(os.path.realpath(__file__)) + "/inputs" |
|
|
| with tempfile.TemporaryDirectory() as tmpdirname: |
| |
| shutil.copytree(src_path, tmpdirname, dirs_exist_ok=True) |
|
|
| |
| with open(f"{tmpdirname}/resume.tex", "w") as f: |
| f.write(latex_data) |
|
|
| |
| latex_process = subprocess.Popen(latex_command, cwd=tmpdirname) |
| latex_process.wait() |
|
|
| |
| with open(f"{tmpdirname}/resume.pdf", "rb") as f: |
| pdf_data = f.read() |
|
|
| return pdf_data |
|
|