Skip to content

Instantly share code, notes, and snippets.

@yhs0602
Created April 25, 2024 08:38
Show Gist options
  • Save yhs0602/de1d043ef57ebe30ca00d2df61cda582 to your computer and use it in GitHub Desktop.
Save yhs0602/de1d043ef57ebe30ca00d2df61cda582 to your computer and use it in GitHub Desktop.
jpg2pdf.py
import sys
import os
# create tex file first
with open("tmp.tex", "w", encoding="utf8") as out:
out.write("\\documentclass{article}\n")
out.write("\\usepackage{float}\n")
out.write("\\usepackage{graphicx}\n")
out.write("\\usepackage[a4paper, total={6in, 8in}]{geometry}\n")
out.write("\\begin{document}\n")
for image in sys.argv[1:]:
print(image)
out.write("\\begin{figure}\n")
out.write("\\includegraphics[width=\\linewidth, angle=0]{"+image+"}\n")
out.write("\\end{figure}\n")
out.write("\\pagebreak\n")
out.write("\\end{document}\n")
os.system("pdflatex tmp.tex")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment