Introduction

Aspose.TeX FOSS for Python is a free, MIT-licensed TeX typesetting engine that runs entirely in Python – no LaTeX installation, no Perl runtime, no external TeX distribution required. Install it with a single package manager command and call TeXJob.run() to convert TeX markup into PDF, DVI, or SVG output.

The library is designed for document pipelines, math rendering, and academic publishing applications where TeX markup needs to be processed programmatically. It accepts input from file paths (FileInputSource) or in-memory strings (StringInputSource), making it suitable for both batch workflows and dynamic content generation.

Aspose.TeX FOSS is published on PyPI under the MIT license. Commercial use is permitted without restriction.


Key Features

PDF Output via PdfDevice

The PdfDevice output device writes typeset content to a PDF byte stream. Construct a TeXJob with a PdfDevice and call run() to receive PDF bytes:

from aspose_tex import TeXJob, TeXOptions
from aspose_tex import PdfDevice
from aspose_tex import StringInputSource

source = StringInputSource("Hello world!")
job = TeXJob(source, PdfDevice(), options=TeXOptions())
pdf_bytes = job.run()

SVG Output via SvgDevice

SvgDevice renders each typeset page as an SVG graphic. The get_all_pages() method returns a list of SVG byte strings, one per page:

from aspose_tex import TeXJob, TeXOptions
from aspose_tex import SvgDevice
from aspose_tex import StringInputSource

device = SvgDevice()
job = TeXJob(StringInputSource("Hello world!"), device, options=TeXOptions())
job.run()
pages = device.get_all_pages()

DVI Output via DviDevice

DviDevice produces Device Independent (DVI) output bytes – the intermediate format used by traditional TeX workflows before final rendering:

from aspose_tex import TeXJob, TeXOptions
from aspose_tex import DviDevice
from aspose_tex import StringInputSource

source = StringInputSource("Hello world!")
job = TeXJob(source, DviDevice(), options=TeXOptions())
dvi_bytes = job.run()

File-Based Input with FileInputSource

FileInputSource reads TeX markup from a file on disk:

from aspose_tex import TeXJob, TeXOptions
from aspose_tex import PdfDevice
from aspose_tex import FileInputSource

job = TeXJob(FileInputSource("document.tex"), PdfDevice(), options=TeXOptions())
pdf_bytes = job.run()

In-Memory Input with StringInputSource

StringInputSource accepts raw TeX markup as a Python string:

from aspose_tex import TeXJob, TeXOptions
from aspose_tex import PdfDevice
from aspose_tex import StringInputSource

job = TeXJob(StringInputSource("Hello, world!"), PdfDevice(), options=TeXOptions())
pdf_bytes = job.run()

Quick Start

Install the package:

pip install aspose-tex>=26.5

Typeset a TeX string to PDF:

from aspose_tex import TeXJob, TeXOptions
from aspose_tex import PdfDevice
from aspose_tex import StringInputSource

pdf_bytes = TeXJob(StringInputSource("Hello!"), PdfDevice(), options=TeXOptions()).run()
with open("output.pdf", "wb") as f:
    f.write(pdf_bytes)

Supported Formats

FormatExtensionReadWrite
PDF.pdf
DVI.dvi
SVG.svg

Input is TeX markup supplied as a file path or in-memory string.


Open Source and Licensing

Aspose.TeX FOSS for Python is published under the MIT license. The package is available on PyPI as aspose-tex. Commercial use is permitted without fees or restrictions.


Getting Started