PsDocument

Overview

PsDocument is a class in Aspose.Page FOSS for Python.

Represents a loaded or editable PS/EPS document.

This class provides 14 methods for working with PsDocument objects in Python programs. Available methods include: add_page, as_bytes, create, from_bytes, from_file, get_page, get_xmp, insert_page, remove_page, remove_xmp, save, set_xmp, and 2 additional methods. All public members are accessible to any Python application after installing the Aspose.Page FOSS for Python package. Properties: data, dirty, dsc, header, is_eps, pages, and 3 more.

Properties

NameTypeAccessDescription
databytesReadGets the data.
is_epsboolReadGets the is eps.
dscDscMetadata | NoneReadGets the dsc.
source_pathstr | NoneReadGets the source path.
pageslist[PsPage]ReadGets the pages.
prologlist[str]ReadGets the prolog.
trailerlist[str]ReadGets the trailer.
headerstr | NoneReadGets the header.
dirtyboolReadGets the dirty.

Methods

SignatureDescription
create(is_eps: bool, page_size: tuple[float, float])"PsDocument"Create a new PS/EPS document with a single empty page.
from_bytes(data: bytes)"PsDocument"Create a document from bytes and detect EPS metadata.
from_file(path: str)"PsDocument"Create a document from a file path.
add_page(size: tuple[float, float] | None)PsPageAppend a new page and return it.
insert_page(index: int, size: tuple[float, float] | None)PsPageInsert a new page at the provided index and return it.
remove_page(index: int)Remove the page at the provided index.
get_page(index: int)PsPageReturn the page at the provided index.
save(path: str | None)bytesSerialize the document to bytes and optionally write to a file.
as_bytes()bytesReturn the raw document bytes.
get_xmp()str | NoneReturn XMP metadata from an EPS document, if present.
set_xmp(xmp_xml: str)Set XMP metadata on an EPS document.
remove_xmp()Remove XMP metadata from an EPS document.
to_pdf(options: "PdfSaveOptions | None")bytesExport the document to PDF bytes.
to_image(options: "ImageSaveOptions")bytesExport the document to raster image bytes.

See Also