Hoe Outputformaten te Gebruiken in Python
Hoe outputformaten te gebruiken in Python
Aspose.TeX FOSS voor Python ondersteunt drie outputformaten via uitwisselbare apparaatklassen: PDF via PdfDevice, DVI via DviDevice, en SVG via SvgDevice. Elk apparaat wordt als tweede argument doorgegeven aan TeXJob. PdfDevice en DviDevice geven bytes terug van de run()-aanroep. SvgDevice slaat per-pagina SVG-gegevens intern op; haal ze op met get_all_pages() nadat run() is geretourneerd.
Genereer 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)Genereer 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])Genereer 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)Samenvatting
| Formaat | Device | Retourwaarde van run() | Notes |
|---|---|---|---|
PdfDevice | bytes | Draagbaar formaat | |
| DVI | DviDevice | bytes | Traditionele TeX intermediair |
| SVG | SvgDevice | None | Pagina’s via get_all_pages() |