Created
April 25, 2024 08:38
-
-
Save yhs0602/de1d043ef57ebe30ca00d2df61cda582 to your computer and use it in GitHub Desktop.
jpg2pdf.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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