Merge PostScript files to PDF using Python

You can check the quality of Aspose.Page PS Merger and view the results via free online PostScipt Merger

Take the next easy steps to combine several PS files into a single PDF via Python:

  1. Initialize an input stream for the first input PS file.
  2. Initialize an output stream for output PDF document.
  3. Create an array of PS files that will be merged with the first one.
  4. Create an instance of PsDocument from the previously created input stream.
  5. Use PdfSaveOptions to specify AdditionalFontsFolder and SuppressError boolean value.
  6. Create an instance of PdfDevice from created earlier output stream.
  7. Merge PostScript files with created document and save it as PDF with PDF save options.

Following code snippet shows how to merge PS files to PDF document in Python:

 1# For complete examples and data files, please go to
 3# The path to the documents directory.
 4data_dir = Util.get_data_dir_working_with_document_merging()
 5# Initialize PDF output stream
 6pdf_stream = open(data_dir + "outputPDF_out.pdf", "wb")
 7# Initialize the first PostScript file input stream
 8ps_stream = open(data_dir + "", "rb",)
 9document = PsDocument(ps_stream)
11# Create an array of PostScript files that will be merged with the first one
12files_for_merge = [ data_dir + "", data_dir + "" ]
14# If you want to convert Postscript file despite of minor errors set this flag
15suppress_errors = True
17#Initialize options object with necessary parameters.
18options = PdfSaveOptions(suppress_errors)
19# If you want to add special folder where fonts are stored. Default fonts folder in OS is always included.
20options.additional_fonts_folders = [ """{FONT_FOLDER}""" ]
22# Default page size is 595x842 and it is not mandatory to set it in PdfDevice
23device = PdfDevice(pdf_stream)
24# But if you need to specify size and image format use following line
25#Aspose.Page.EPS.Device.PdfDevice device = new Aspose.Page.EPS.Device.PdfDevice(pdfStream, new aspose.pydrawing.Size(595, 842));
28    document.merge(files_for_merge, device, options)
30    ps_stream.close()
31    pdf_stream.close()

See PS merge in .NET, Java and C++.

Let’s consider PdfSaveOptions. Using this class we can assign different conversion parameters while merging PS files to PDF.

Evaluate PS merging online on our PS Merger.

You can download examples and data files from GitHub.

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.