Aspose.Page FOSS for Python は、PostScript (PS) を変換するための無料かつオープンソースのライブラリです、
Encapsulated PostScript (EPS) および XPS ドキュメントを Python アプリケーションで扱います。単一の pip install aspose-page-foss コマンドでインストールし、PDF へのエクスポートを開始します、
ラスタ画像へのエクスポートも、プロプライエタリなランタイムやシステム依存なしで行えます。
The library exposes a clean API built around PsDocument and XpsDocument. Load a document
with from_file() or from_bytes(), then call to_pdf() to obtain a PDF byte stream, orto_image() with an ImageSaveOptions instance to render to PNG or JPEG at a specified DPI.
An optional MCP server exposes ps_to_pdf, ps_to_image, xps_to_pdf, and xps_to_image
as remote conversion tools using FastMCP.
Because the library has no dependency on native Office libraries or Ghostscript, it runs
identically on Windows, Linux, and macOS, including CI runners and Docker containers. The
codebase is MIT-licensed and hosted on GitHub. Developers who need the full commercial API
can use Aspose.Page for Python alongside these open-source resources. For the enterprise product, see Aspose.Page for Python — Enterprise Product.
PsDocument.from_file() を呼び出し、続いて to_pdf() を呼び出して、ドキュメントを PDF バイト配列としてエクスポートします。PsDocument.from_file() は .ps と .eps の両方のファイル拡張子を受け付けます。ImageSaveOptions(format="png", dpi=150) を to_image() に渡します。bytes を返します — 一時ファイルは不要です。PsDocument.from_bytes() を使用します。XpsDocument.from_file() を呼び出し、次に to_pdf() を呼び出して XPS ファイルを PDF バイト配列としてエクスポートします。to_image() を ImageSaveOptions と共に呼び出し、XPS ページを PNG または JPEG にレンダリングします。XpsDocument.from_bytes() を使用します。add_page()、get_page()、および remove_page() を使用します。XpsPackage.from_file() を使用します。create_server() は ps_to_pdf、ps_to_image、xps_to_pdf、および xps_to_image を FastMCP 経由で MCP ツールとして登録します。eps_metadata ツールは EPS ファイルからバウンディングボックスと DSC ヘッダー フィールドを抽出します。McpInput はファイルパスまたは Base64 エンコードされたバイトを受け付け、McpOutput は Base64 バイトを返すか、パスへ書き込みます。McpConversionOptions は画像変換の出力形式と DPI を制御します。RenderDocument を begin_page()、add_path()、add_text()、add_image()、および end_page() で構築します。PdfMetadata インスタンスを渡し、write(doc) を呼び出して任意の RenderDocument から PDF バイト配列を生成します。title、creator、producer、creation_date、および trapped フィールドを設定します。RenderDocument を RasterSurface にレンダリングし、encode_png() または encode_bmp() でエンコードします。RasterRenderer を使用してドキュメントをレンダリングし,自動化テストでピックス出力を比較します.FontResolver と build_embedded_font() を使用して TrueType のフォन्टを埋め込む.Paint オブジェクトを適用します.ファイルにアクセスするには PsDocument.from_file() を呼び出し,それを PDF バイトストリームとしてエクスポートするために to_pdf() を呼べます.
from pathlib import Path
from aspose.page.ps.document import PsDocument
ps = PsDocument.from_file("input.ps")
output_pdf = ps.to_pdf()
Path("output.pdf").write_bytes(output_pdf)
PsDocument クラスも同じ EPSファイルを処理します.必要なフォーマットとDPIを持つImageSaveOptions を to_image() に渡す.
from aspose.page.ps.document import PsDocument
from aspose.page.ps.output import ImageSaveOptions
eps = PsDocument.from_file("input.eps")
output_png = eps.to_image(ImageSaveOptions(format="png", dpi=150))
with open("output.png", "wb") as f:
f.write(output_png)
ファイルにアクセスするには XpsDocument.from_file() を呼び出し,それを PDF バイトストリームとしてエクスポートするために to_pdf() を呼べます.
from pathlib import Path
from aspose.page.xps.document import XpsDocument
xps = XpsDocument.from_file("input.xps")
output_pdf = xps.to_pdf()
Path("output.pdf").write_bytes(output_pdf)
Aspose.Page PythonのFOSSは,商業的およびプロプライエータアプリケーションで使用することを許可するMITライセンスでリリースされています.
図書館はGhostscript,Adobe Reader,またはネイティブランタイムに依存していません.Windows,LinuxおよびmacOSで実行されます.
図書館はPostScript (.ps),Encapsulated PostScript (eps) とXPS (.xps).ファイルを読み取ります.
図書室は,to_pdf() を使って PDF に輸出し, PNG または JPEG のラスター画像を to_image() で ImageSaveOptions.でエクスポートします.
ファイルを書く必要がない. from_bytes() を使って,原始バイトから読み込みし,to_pdf() または to_image() から返済したバイットを直接書き込む.