כיצד לעבוד עם קבצי PS ו- EPS ב- Python
כיצד לעבוד עם קבצי PS ו- EPS ב- Python
PsDocument הוא נקודת הכניסה להורדה ולייצוא של קבצי PostScript ו- EPS. שימוש from_file() להעלות מסמך על פי מסלול, או from_bytes() להעלות את הזיכרון בייט. כל התוצאות הוחזרו כ bytes אין קבצים זמניים שנכתבו על הדיסק.
להעלות קובץ PS או EPS
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)ייצוא ל- 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())ייצוא ל- 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)))מחירים מתוך 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()