Wie man Ausgabeformate in Python verwendet

Wie man Ausgabeformate in Python verwendet

Wie man Ausgabeformate in Python verwendet

Aspose.TeX FOSS für Python unterstützt drei Ausgabeformate über austauschbare Geräteklassen: PDF über PdfDevice, DVI über DviDevice und SVG über SvgDevice. Jedes Gerät wird als zweites Argument an TeXJob übergeben. PdfDevice und DviDevice geben Bytes aus dem Aufruf von run() zurück. SvgDevice speichert pro Seiten SVG-Daten intern; rufen Sie sie mit get_all_pages() ab, nachdem run() zurückgekehrt ist.

PDF erzeugen

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 erzeugen

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 erzeugen

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)

Zusammenfassung

FormatDeviceRückgabewert von run()Notes
PDFPdfDevicebytesTragbares Format
DVIDviDevicebytesTraditionelles TeX-Zwischenelement
SVGSvgDeviceNoneSeiten über get_all_pages()

Siehe auch

 Deutsch