Hur man arbetar med PS och EPS-filer i Python
Hur man arbetar med PS och EPS-filer i Python
PsDocument är en inresa till laddning och export av PostScript- och EPS-filer. Användning from_file() att ladda ett dokument per väg, eller from_bytes() Ladda från in-memory bytes. Hela produktionen returneras som bytes - Inga tillfälliga filer skrivs på en skiva.
Ladda upp en PS eller EPS-fil
from aspose.page.ps.document import PsDocument
ps = PsDocument.from_file("input.ps")
eps = PsDocument.from_file("input.eps")
print("Is EPS:", eps.is_eps)Export till PDF
from pathlib import Path
from aspose.page.ps.document import PsDocument
ps = PsDocument.from_file("input.ps")
Path("output.pdf").write_bytes(ps.to_pdf())Export till PNG
from pathlib import Path
from aspose.page.ps.document import PsDocument
from aspose.page.ps.output import ImageSaveOptions
eps = PsDocument.from_file("input.eps")
Path("output.png").write_bytes(eps.to_image(ImageSaveOptions(format="png", dpi=150)))Ladda från bytes
from aspose.page.ps.document import PsDocument
with open("input.ps", "rb") as f:
doc = PsDocument.from_bytes(f.read())
pdf_bytes = doc.to_pdf()