Aspose.TeX FOSS for Python (aspose-tex) is a free, MIT-licensed TeX typesetting engine for Python developers. It generates PDF, DVI, or SVG output — no LaTeX installation or external runtime required.
The library exposes three output devices: PdfDevice for PDF output, DviDevice for
DVI output, and SvgDevice for multi-page SVG output. The TeXJob class is the main
entry point; it accepts a FileInputSource or StringInputSource and an output device,
then runs the typesetting engine when .run() is called.
Aspose.TeX FOSS for Python is released under the MIT license. It runs in Python 3.10+
environments on all major operating systems including Linux, macOS, and Windows. Install
with pip install aspose-tex>=26.5. No Ghostscript or TeX Live dependency required. For the enterprise product family, see Aspose.TeX — Enterprise Product Family.
PdfDevice wraps PdfWriter to produce PDF 1.4 output bytesDviDevice wraps DviWriter for DVI outputTeXJob.run() returns bytes or writes to a Path or BytesIOSvgDevice wraps SvgWriter for SVG 1.1 multi-page outputget_bytes() returns SVG bytes for single-page documentsget_all_pages() returns a list of bytes for multi-page documentsStringInputSource — provide TeX markup as a Python stringFileInputSource — read TeX source from a file path on diskInputReader — base protocol for custom input implementationsTeXOptions.load_format — control format pre-loadingFontManager provides access to TFM font metricsFontEncoding maps TeX character codes to PostScript glyph namesFontMetrics exposes width, height, and depth metrics per characterTeXOptions.extra_font_paths — extend the font search pathInstall with pip install aspose-tex>=26.5, then typeset a TeX string to obtain PDF bytes:
from aspose_tex import StringInputSource, PdfDevice, TeXJob, TeXOptions
opts = TeXOptions(load_format=False)
result = TeXJob(
StringInputSource(r"Hello -- done"),
PdfDevice(),
options=opts,
).run()
# result is bytes containing a valid PDF
Read TeX source from a file and export each page as SVG:
from aspose_tex import FileInputSource, SvgDevice, TeXJob, TeXOptions
opts = TeXOptions(load_format=False)
device = SvgDevice()
TeXJob(FileInputSource("input.tex"), device, options=opts).run()
pages = device.get_all_pages() # list[bytes] of SVG per page
Use DviDevice to produce DVI output:
from aspose_tex import StringInputSource, DviDevice, TeXJob, TeXOptions
opts = TeXOptions(load_format=False)
result = TeXJob(
StringInputSource(r"\hbox{Test}-- done"),
DviDevice(),
options=opts,
).run()
# result is bytes containing DVI data
Aspose.TeX FOSS for Python is published under the MIT license. Commercial use is permitted without fees or restrictions.
No. It is a pure Python package requiring no LaTeX installation, Perl runtime, or external TeX distribution.
PDF (PdfDevice), DVI (DviDevice), and SVG (SvgDevice). Input is TeX markup from a file or string.
Use TeXJob(StringInputSource(content), PdfDevice(), options=TeXOptions()).run() to receive PDF bytes.
Yes. Use StringInputSource to pass TeX markup directly without writing to disk.