Introduction
Aspose.Page FOSS for Python is a free, open-source library for converting PostScript (PS),
Encapsulated PostScript (EPS), and XPS documents to PDF and raster images in Python
applications. It is distributed under the MIT license and available on PyPI as
aspose-page-foss.
The library provides two top-level document classes: PsDocument for PS and EPS files,
and XpsDocument for XPS files. Both classes expose to_pdf() and to_image() methods
that return byte arrays, making it straightforward to integrate into file processing
pipelines without writing temporary files.
Because the library has no dependency on Ghostscript, Adobe Reader, or any native Office runtime, it runs on Windows, Linux, and macOS including CI runners and Docker containers. Developers who need the full commercial API with advanced rendering features can continue using the enterprise Aspose.Page for Python product alongside these open-source utilities.
What’s Included
PS and EPS to PDF Conversion
PsDocument handles both PostScript (.ps) and Encapsulated PostScript (.eps) files
through the same class interface. Call PsDocument.from_file() to load a document, then
call to_pdf() to obtain the result as a PDF byte array.
from pathlib import Path
from aspose.page.ps.document import PsDocument
ps = PsDocument.from_file("input.ps")
pdf_bytes = ps.to_pdf()
Path("output.pdf").write_bytes(pdf_bytes)
The from_bytes() class method accepts raw bytes, so documents arriving from network
streams or file uploads can be processed without writing to disk first.
PS and EPS to Raster Image
To render a PS or EPS document to a PNG or JPEG image, pass an ImageSaveOptions instance
to to_image(). Set the format property to "png" or "jpeg" and the dpi property
to control the output resolution.
from aspose.page.ps.document import PsDocument
from aspose.page.ps.output import ImageSaveOptions
eps = PsDocument.from_file("input.eps")
opts = ImageSaveOptions(format="png", dpi=150)
png_bytes = eps.to_image(opts)
XPS to PDF and Image
XpsDocument loads XPS files and exposes the same to_pdf() and to_image() interface as
PsDocument. Call XpsDocument.from_file() to load an XPS document, then convert to
the desired output format.
from pathlib import Path
from aspose.page.xps.document import XpsDocument
from aspose.page.ps.output import ImageSaveOptions
xps = XpsDocument.from_file("input.xps")
pdf_bytes = xps.to_pdf()
Path("output.pdf").write_bytes(pdf_bytes)
png_bytes = xps.to_image(ImageSaveOptions(format="png", dpi=96))
In-Memory Processing
All conversion methods return bytes objects. Temporary files are never required unless the
application explicitly writes them. The from_bytes() constructors on both PsDocument and
XpsDocument accept raw bytes as input, so the entire pipeline can stay in memory.
from aspose.page.ps.document import PsDocument
def convert_ps_in_memory(ps_bytes: bytes) -> bytes:
doc = PsDocument.from_bytes(ps_bytes)
return doc.to_pdf()
MCP Server Integration
The library includes an optional MCP server that exposes conversion functions as remote
tools using FastMCP. The server registers ps_to_pdf, ps_to_image, xps_to_pdf, and
xps_to_image as callable tools. McpInput accepts a file path or base64-encoded bytes;
McpOutput returns base64 bytes or writes to a path.
FastMCP is an optional dependency — the core conversion functionality works without it. The MCP server is useful for making the library callable from AI agent pipelines, microservices, and editors that support MCP tool servers.
Quick Start
Install the library with pip:
pip install aspose-page-foss>=0.1.0
The following example covers the most common use case — converting a PS file to PDF and saving it to disk:
from pathlib import Path
from aspose.page.ps.document import PsDocument
from aspose.page.ps.output import ImageSaveOptions
# Convert PS to PDF
ps = PsDocument.from_file("document.ps")
Path("document.pdf").write_bytes(ps.to_pdf())
# Convert EPS to PNG at 150 DPI
eps = PsDocument.from_file("illustration.eps")
opts = ImageSaveOptions(format="png", dpi=150)
Path("illustration.png").write_bytes(eps.to_image(opts))
# Convert XPS to PDF
from aspose.page.xps.document import XpsDocument
xps = XpsDocument.from_file("document.xps")
Path("document.pdf").write_bytes(xps.to_pdf())
Supported Formats
Aspose.Page FOSS for Python reads PostScript (.ps), Encapsulated PostScript (.eps), and
XML Paper Specification (.xps) files. Output formats are PDF (.pdf) and raster images
(.png, .jpeg). All conversions are export-only — the library does not write PS, EPS, or XPS.
Open Source & Licensing
Aspose.Page FOSS for Python is released under the MIT license. The source code is hosted on GitHub at github.com/aspose-page-foss/Aspose.Page-FOSS-for-Python. Commercial use is permitted without restriction under the MIT terms.