Python에서 PS 및 EPS 파일 작업하기
Python에서 PS 및 EPS 파일 작업 방법
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)))바이트에서 로드
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()