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. No Ghostscript or TeX Live dependency required. For the enterprise product, see Aspose.TeX for Python — Enterprise Product.
asposefoss/tex is not yet published — build from source until it ships. See the project README for build instructions.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 diskInputSource — abstract base class implemented by both input typesTeXOptions.load_format — control format pre-loadingTeXOptions.job_name — set the job name used in log messages and default output filenamesTeXOptions.magnification — control the TeX magnification factorTeXOptions.extra_font_paths — extend the font search path with custom directoriesTeXOptions.extra_format_paths — extend the search path for format and \input filesInstall the package (see above), 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.