Comment utiliser le moteur TeX en Python
Comment utiliser le moteur TeX en Python
TeXJob est le point d’entrée principal pour le moteur FOSS. Il accepte un source d’entrée, un output et optionnel TeXOptions,Puis il courra le Le pipeline de type quand run() On l’appelle !.
Télécharger à PDF
from aspose_tex import TeXJob, TeXOptions, PdfDevice, StringInputSource
pdf_bytes = TeXJob(StringInputSource("Hello!"), PdfDevice(), options=TeXOptions()).run()
with open("output.pdf", "wb") as f:
f.write(pdf_bytes)Le type de SVG
from aspose_tex import TeXJob, TeXOptions, SvgDevice, StringInputSource
device = SvgDevice()
TeXJob(StringInputSource("Hello!"), device, options=TeXOptions()).run()
for i, svg in enumerate(device.get_all_pages()):
with open(f"page_{i}.svg", "wb") as f:
f.write(svg)Télécharger DVI
from aspose_tex import TeXJob, TeXOptions, DviDevice, StringInputSource
dvi_bytes = TeXJob(StringInputSource("Hello!"), DviDevice(), options=TeXOptions()).run()