Hur man använder TeX-motorn i Python
Hur man använder TeX-motorn i Python
TeXJob är den huvudsakliga ingångspunkten för Aspose.TeX FOSS-motorn. Det accepterar en Inträde källa, en utgångsutrustning och valfri TeXOptions,Och sedan kör de Typ av pipeline när run() är kallad .
Typ till 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)Typ till 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)Typ till DVI
from aspose_tex import TeXJob, TeXOptions, DviDevice, StringInputSource
dvi_bytes = TeXJob(StringInputSource("Hello!"), DviDevice(), options=TeXOptions()).run()