Working with PS Document | Python

PS and EPS extensions are associated with the PostScript and Encapsulated PostScript languages, respectively, both developed by Adobe.

PS is a versatile page description language that utilizes graphics operators, procedures, control operators, and variables.

EPS is a subset of PostScript with certain restrictions. Some PostScript operators are not allowed in EPS files, which must adhere to the PostScript Document Structuring Conventions Specifications, including the use of structural comments. EPS files were primarily designed for describing single-page graphics that can be encapsulated within PostScript files and their derivatives.

The Aspose.Page library for Python via .NET enables the creation of both PS and EPS files with appropriate graphics elements. However, for this guide, we will focus solely on the PS file type. Therefore, the following code snippet demonstrates how to create a PS file:

1#Create save options
2options = PsSaveOptions()
3
4#Create an output stream for PS document
5out_ps_stream = open(dir + "document.ps", "wb")
6
7#Create a PS document
8document = PsDocument(out_ps_stream, options, false)

To create EPS files you shoulf use the following code:

 1#Create save options
 2options = PsSaveOptions()
 3
 4#Set a save format as EPS
 5options.setSaveFormat(PsSaveFormat.EPS);
 6
 7#Create output stream for EPS document
 8out_eps_stream = open(dir + "document.eps", "wb")
 9
10#Create PS document
11document = PsDocument(out_eps_stream, options, false)

See working with PS documents in .NET, Java.

Aspose.Page library can create only static PS/EPS documents. Control operators are not supported.

At this moment Aspose.Page library can only create PostScript documents, not edit it.

This section provides details on handling PS files through the Aspose.Page API solution for Python. Within this chapter, you’ll discover subsequent articles containing code examples illustrating the functionality in action.

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.