简体   繁体   English

将 Latex 文件转换为 PDF

[英]Convert Latex file to PDF

I am trying to convert a latex document to a pdf document are there any commands in python by which I can do this.我正在尝试将 latex 文档转换为 pdf 文档,python 中是否有任何命令可以做到这一点。

From here这里

Try this please.请试试这个。

import os  
os.system("pdflatex mylatex.tex")

in addition, you can use os.system("mv mylatex.pdf path/to/directory") to move the pdf to any specific location此外,您可以使用os.system("mv mylatex.pdf path/to/directory")将 pdf 移动到任何特定位置

Alternatively, and more "clean" solution is without os.system() that runs the shell here.或者,更“干净”的解决方案是没有在此处运行 shell 的os.system() You can use subprocess.check_call(['pdflatex', 'mylatex.tex']) instead.您可以改用subprocess.check_call(['pdflatex', 'mylatex.tex']) To save the result in a specific location: pass the appropriate command-line argument to pdflatex or use shutil.move() .要将结果保存在特定位置:将适当的命令行参数传递给pdflatex或使用shutil.move()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM