在Python中如何使用输入源?

在Python中如何使用输入源?

在Python中如何使用输入源?

Aspose.TeX FOSS for Python provides two input source classes: FileInputSource 用于从磁盘上读取,以及 StringInputSource 对于内存的TeX标记.

从文件中读取

FileInputSource 从现有文件中读取TeX标记:

from aspose_tex import TeXJob, TeXOptions, PdfDevice, FileInputSource

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

从线上读取

StringInputSource 接受TeX标记作为Python字符串:

from aspose_tex import TeXJob, TeXOptions, PdfDevice, StringInputSource

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

选择输入源

使用情况 FileInputSource 在与 .tex 在磁盘上的文件.使用 StringInputSource 在编程生成TeX标记或处理用户提供的字符串时.

See Also

 中文