كيفية استخدام تنسيقات المخرجات في بايثون

كيفية استخدام تنسيقات المخرجات في بايثون

كيفية استخدام تنسيقات المخرجات في بايثون

Aspose.TeX FOSS for Python supports three output formats through interchangeable device classes: PDF via PdfDevice, DVI via DviDevice, and SVG via SvgDevice. Each device is passed as the second argument to TeXJob. PdfDevice and DviDevice return bytes from the run() call. SvgDevice stores per-page SVG data internally; retrieve it with get_all_pages() after run() returns.

إنتاج 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)

ملخص

شكلالجهازقيمة العودة من run()ملاحظات
PDFPdfDevicebytesتنسيق محمول
DVIDviDevicebytesمنتصف TeX التقليدي
SVGSvgDeviceNoneصفحات عبر get_all_pages()

انظر أيضا

 العربية