Quick Start
Quick Start
Aspose.TeX FOSS for Python follows a simple three-step pattern: create an input source, choose an output device, and call TeXJob.run() to perform typesetting. FileInputSource reads TeX markup from a file; StringInputSource accepts in-memory strings. PdfDevice returns PDF bytes, DviDevice returns DVI bytes, and SvgDevice stores per-page SVG data for retrieval with get_all_pages(). No LaTeX installation or configuration file is required.
Typeset to PDF
from aspose_tex import TeXJob, TeXOptions, PdfDevice, StringInputSource
source = StringInputSource("Hello, world!")
pdf_bytes = TeXJob(source, PdfDevice(), options=TeXOptions()).run()
with open("output.pdf", "wb") as f:
f.write(pdf_bytes)Typeset to SVG
from aspose_tex import TeXJob, TeXOptions, SvgDevice, StringInputSource
device = SvgDevice()
TeXJob(StringInputSource("Hello!"), device, options=TeXOptions()).run()
svg_pages = device.get_all_pages()
with open("page0.svg", "wb") as f:
f.write(svg_pages[0])Typeset to DVI
from aspose_tex import TeXJob, TeXOptions, DviDevice, StringInputSource
dvi_bytes = TeXJob(StringInputSource("Hello!"), DviDevice(), options=TeXOptions()).run()
with open("output.dvi", "wb") as f:
f.write(dvi_bytes)Typeset from a File
from aspose_tex import TeXJob, TeXOptions, PdfDevice, FileInputSource
pdf_bytes = TeXJob(FileInputSource("document.tex"), PdfDevice(), options=TeXOptions()).run()