Pythonで出力形式を使用する方法

Pythonで出力形式を使用する方法

Python で出力フォーマットを使用する方法

Aspose.TeX FOSS for Python は、入れ替え可能なデバイスクラスを通じて 3 つの出力フォーマットをサポートします: PdfDevice 経由の PDF、DviDevice 経由の DVI、そして SvgDevice 経由の SVG。各デバイスは TeXJob の第2引数として渡されます。PdfDevice と DviDevice は run() 呼び出しからバイト列を返します。SvgDevice はページごとの SVG データを内部に保存します;run() が返った後に get_all_pages() で取得してください。

PDF を生成

from aspose_tex import TeXJob, TeXOptions, PdfDevice, StringInputSource

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

SVG を生成

from aspose_tex import TeXJob, TeXOptions, SvgDevice, StringInputSource

device = SvgDevice()
TeXJob(StringInputSource("Hello!"), device, options=TeXOptions()).run()
svg_pages = device.get_all_pages()
with open("page0.svg", "wb") as f:
    f.write(svg_pages[0])

DVI を生成

from aspose_tex import TeXJob, TeXOptions, DviDevice, StringInputSource

dvi_bytes = TeXJob(StringInputSource("Hello!"), DviDevice(), options=TeXOptions()).run()
with open("output.dvi", "wb") as f:
    f.write(dvi_bytes)

概要

形式Devicerun() の戻り値Notes
PDFPdfDevicebytesポータブル形式
DVIDviDevicebytes従来の TeX 中間
SVGSvgDeviceNoneページ(get_all_pages()経由)

参照

 日本語