---
Product: Aspose.Page
Platform: python
Page Type: index
Canonical URL: https://products.aspose.org/page/python/
---

# Aspose.Page FOSS for Python

Free, MIT-licensed Python library to export PS, EPS, and XPS documents as PDF and raster images. No Office required.

Aspose.Page FOSS for Python is a free, MIT-licensed library for exporting PostScript, EPS, and XPS files as PDF and PNG/JPEG. Install with pip. No Office required.

## Open-Source Python Library for PS, EPS, and XPS Conversion

Aspose.Page FOSS for Python is a free, open-source library for converting PostScript (PS),
Encapsulated PostScript (EPS), and XPS documents in Python applications. See the install
section below to get started exporting documents to PDF and raster images without any
proprietary runtime or system dependency.

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, or
`to_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](https://products.aspose.com/page/python-net/).

## Convert PS and EPS Documents

- **PS to PDF:** Call `PsDocument.from_file()` then `to_pdf()` to export the document as a PDF byte array.
- **EPS to PDF:** `PsDocument.from_file()` accepts both `.ps` and `.eps` file extensions.
- **PS/EPS to image:** Pass an `ImageSaveOptions(format="png", dpi=150)` to `to_image()` for PNG or JPEG output.
- **In-memory processing:** All conversions return `bytes` — no temporary files required.
- **From bytes:** Use `PsDocument.from_bytes()` to process PS/EPS data from a network stream or upload.

## Where PS/EPS Conversion Is Used

- **Document pipelines:** Export legacy PostScript reports to PDF for archiving or distribution.
- **Print workflows:** Transform PS output from print drivers into PDF or image previews.
- **EPS asset processing:** Rasterize EPS illustrations to PNG for web or documentation use.
- **Batch automation:** Process directories of PS/EPS files in CI or cron jobs without a GUI.

## Convert XPS Documents

- **XPS to PDF:** Call `XpsDocument.from_file()` then `to_pdf()` to export the XPS file as a PDF byte array.
- **XPS to image:** Call `to_image()` with `ImageSaveOptions` to render XPS pages to PNG or JPEG.
- **From bytes:** Use `XpsDocument.from_bytes()` for in-memory XPS data from uploads or streams.
- **Page access:** Use `add_page()`, `get_page()`, and `remove_page()` to work with individual pages.
- **XPS package reading:** Use `XpsPackage.from_file()` to inspect raw XPS package parts.

## Where XPS Conversion Is Used

- **Windows print spool:** Export XPS spool files from the Windows print subsystem to PDF or image.
- **Document archiving:** Transform XPS files to universally readable PDF for long-term storage.
- **Preview generation:** Render XPS pages to PNG thumbnails for document management systems.
- **Cross-platform use:** Process XPS files on Linux and macOS servers where native viewers are unavailable.

## MCP Server for Remote Conversion

- **Tool exposure:** `create_server()` registers `ps_to_pdf`, `ps_to_image`, `xps_to_pdf`, and `xps_to_image` as MCP tools via FastMCP.
- **EPS metadata:** The `eps_metadata` tool extracts bounding box and DSC header fields from EPS files.
- **Input/output types:** `McpInput` accepts a file path or base64-encoded bytes; `McpOutput` returns base64 bytes or writes to a path.
- **Conversion options:** `McpConversionOptions` controls output format and DPI for image conversions.
- **Optional dependency:** FastMCP is required only for MCP server hosting; core conversion works without it.

## MCP Use Cases

- **AI agent pipelines:** Expose document conversion as a tool callable by Claude or other MCP-compatible agents.
- **Microservices:** Run a lightweight conversion service accepting PS/EPS/XPS over HTTP.
- **IDE plugins:** Surface conversion functionality to editors that support MCP tool servers.
- **Workflow automation:** Integrate conversion into n8n or similar low-code automation platforms.

## Render Model and PDF Output

- **RenderModelBuilder:** Build a `RenderDocument` with `begin_page()`, `add_path()`, `add_text()`, `add_image()`, and `end_page()`.
- **PdfWriter:** Pass a `PdfMetadata` instance and call `write(doc)` to produce a PDF byte array from any `RenderDocument`.
- **PdfMetadata:** Set `title`, `creator`, `producer`, `creation_date`, and `trapped` fields on the output PDF.
- **RasterRenderer:** Render a `RenderDocument` to a `RasterSurface`; encode with `encode_png()` or `encode_bmp()`.
- **Unicode encoding:** The PDF output layer writes multi-script Unicode text including CJK and Cyrillic.

## Low-Level Rendering Use Cases

- **Custom PDF generation:** Build pages with vector paths, text, and images without an intermediate PS/XPS file.
- **Pixel-perfect testing:** Use `RasterRenderer` to render documents and compare pixel outputs in automated tests.
- **Font embedding:** Embed TrueType fonts using `FontResolver` and `build_embedded_font()` for correct rendering.
- **Color management:** Apply `Paint` objects with DeviceRGB or CIE-based color spaces to paths and text.

## Convert PS to PDF

Call `PsDocument.from_file()` to access the PostScript file and call `to_pdf()` to export it as a PDF byte stream.

```bash
pip install aspose-page-foss
```

```python
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)
```

## Convert EPS to PNG

The same `PsDocument` class handles EPS files. Pass an `ImageSaveOptions` with the desired format and DPI to `to_image()`.

```python
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)
```

## Convert XPS to PDF

Call `XpsDocument.from_file()` to access the XPS document and call `to_pdf()` to export it as a PDF byte stream.

```python
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)
```

## Frequently Asked Questions

### What license does Aspose.Page FOSS for Python use?

Aspose.Page FOSS for Python is released under the MIT License, permitting use in commercial and proprietary applications.

### Are there any native dependencies?

No. The library has no dependency on Ghostscript, Adobe Reader, or any native runtime. It runs on Windows, Linux, and macOS.

### Which input formats does the library support?

The library reads PostScript (.ps), Encapsulated PostScript (.eps), and XPS (.xps) files.

### Which output formats does the library produce?

The library exports to PDF via `to_pdf()` and to PNG or JPEG raster images via `to_image()` with `ImageSaveOptions`.

### Can I process files in memory without disk I/O?

Yes. Use `from_bytes()` to load from raw bytes and the returned bytes from `to_pdf()` or `to_image()` directly without writing files.

## Support and Learning Resources

- [Documentation](https://docs.aspose.org/page/python/)
- [API References](https://reference.aspose.org/page/python/)
- [Free Support](https://forum.aspose.org/)
- [Contribution](https://contribution.aspose.org/)
- [Blog](https://blog.aspose.org/)
- [New Releases](https://releases.aspose.org/)