How to Use Input Sources in Python
How to Use Input Sources in Python
Aspose.TeX FOSS for Python provides two input source classes: FileInputSource
for reading from disk, and StringInputSource for in-memory TeX markup.
Read from a File
FileInputSource reads TeX markup from an existing file:
from aspose_tex import TeXJob, TeXOptions, PdfDevice, FileInputSource
pdf_bytes = TeXJob(FileInputSource("document.tex"), PdfDevice(), options=TeXOptions()).run()Read from a String
StringInputSource accepts TeX markup as a Python string:
from aspose_tex import TeXJob, TeXOptions, PdfDevice, StringInputSource
tex = "Hello, world!"
pdf_bytes = TeXJob(StringInputSource(tex), PdfDevice(), options=TeXOptions()).run()Choosing an Input Source
Use FileInputSource when working with .tex files on disk. Use StringInputSource
when generating TeX markup programmatically or processing user-supplied strings.