Merge EPS files to PDF using Python

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

Aspose.Page for Python via .NET EPS Merger enables the merging of Encapsulated PostScript (EPS) files into a PDF document on any operating system where the Python Virtual Machine exists.

To perform the EPS to PDF merge, several steps are required:

  1. Initialize an input stream for the first input EPS file.
  2. Initialize an output stream for the output PDF document.
  3. Create an array of EPS files to 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 the earlier created output stream.
  7. Merge EPS files with the created document and save it as a PDF with the specified PDF save options.


The following code snippet demonstrates how to merge EPS files into a PDF document using Python:

 1# For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-Python
 2
 3# The path to the documents directory.
 4data_dir = Util.get_data_dir_working_with_document_merging()
 5# Initialize a 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 + "input.eps", "rb",)
 9document = PsDocument(ps_stream)
10
11# Create an array of PostScript files that will be merged with the first one
12files_for_merge = [ data_dir + "input2.eps", data_dir + "input3.eps" ]
13
14# If you want to convert the Postscript file despite of minor errors set this flag
15suppress_errors = True
16
17# Initialize options object with the necessary parameters.
18options = PdfSaveOptions(suppress_errors)
19# If you want to add a special folder where fonts are stored. Default fonts folder in OS is always included.
20options.additional_fonts_folders = [ """{FONT_FOLDER}""" ]
21
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));
26
27try:
28    document.merge(files_for_merge, device, options)
29finally:
30    ps_stream.close()
31    pdf_stream.close()

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

Let’s consider PdfSaveOptions which enables us to set various conversion parameters during the merging of EPS files into PDFs.

Evaluate EPS merging online on our EPS Merger.

You can download examples and data files from GitHub.

Have any questions about Aspose.Page?



Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.