1. Products
  2.   Aspose.TeX
  3.   Aspose.TeX FOSS for Python

Aspose.TeX FOSS for Python

Free, MIT-licensed Python library to produce PDF, DVI, and SVG output from TeX markup. No LaTeX runtime required.

Aspose.TeX FOSS — Open Source Python TeX Engine

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.

PDF and DVI Output

  • PdfDevice wraps PdfWriter to produce PDF 1.4 output bytes
  • DviDevice wraps DviWriter for DVI output
  • TeXJob.run() returns bytes or writes to a Path or BytesIO
  • In-memory processing — no temporary files required

Use cases

  • Typeset math equations and technical documents to PDF
  • Generate print-ready output from TeX source
  • Batch-convert TeX files in CI/CD pipelines
  • Produce DVI for downstream tooling

SVG Output

  • SvgDevice wraps SvgWriter for SVG 1.1 multi-page output
  • get_bytes() returns SVG bytes for single-page documents
  • get_all_pages() returns a list of bytes for multi-page documents
  • Clean vector output for web and display use

Use cases

  • Render TeX equations as inline SVG for web pages
  • Export typeset figures to scalable vector format
  • Generate diagrams and mathematical notation
  • Serve SVG output from APIs and web services

Flexible Input Sources

  • StringInputSource — provide TeX markup as a Python string
  • FileInputSource — read TeX source from a file path on disk
  • InputReader — base protocol for custom input implementations
  • TeXOptions.load_format — control format pre-loading

Use cases

  • Process dynamically-generated TeX markup in memory
  • Convert TeX files from disk in batch workflows
  • Integrate TeX rendering into web applications
  • Chain TeX processing with other data pipelines

Font Management

  • FontManager provides access to TFM font metrics
  • FontEncoding maps TeX character codes to PostScript glyph names
  • FontMetrics exposes width, height, and depth metrics per character
  • TeXOptions.extra_font_paths — extend the font search path

Use cases

  • Use custom TFM fonts in typesetting jobs
  • Access character metric data programmatically
  • Debug font resolution and encoding issues
  • Extend the engine with additional font directories

Process TeX to PDF

Install 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

Process TeX File to SVG

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

Export TeX to DVI

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

Frequently Asked Questions

What is the licensing model?

Aspose.TeX FOSS for Python is published under the MIT license. Commercial use is permitted without fees or restrictions.

Are there any native dependencies?

No. It is a pure Python package requiring no LaTeX installation, Perl runtime, or external TeX distribution.

Which output formats are supported?

PDF (PdfDevice), DVI (DviDevice), and SVG (SvgDevice). Input is TeX markup from a file or string.

How do I produce PDF output?

Use TeXJob(StringInputSource(content), PdfDevice(), options=TeXOptions()).run() to receive PDF bytes.

Can I read TeX from an in-memory string?

Yes. Use StringInputSource to pass TeX markup directly without writing to disk.

  

Support and Learning Resources