Merge PS/EPS files to PDF using JavaScript

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

Aspose.Page for JavaScript via C++ PS/EPS merger allows merging Encapsulated PostScript (EPS) files to a PDF document on Windows and Linux.
It is necessary to do several steps to perform PS/EPS to PDF merge:

  1. Create file reader ‘const file_reader = new FileReader();’ and read file ‘file_reader.readAsArrayBuffer(e.target.files[0]);’.
  2. Load needed files by using AsposePagePrepare
  3. After the loading of the last file, call AsposePSMergeToPdf and pass the array of file names, the result file name, and SuppressError boolean values to it.
  4. The result JSON contains the file name in fileNameResult.
  5. If the SuppressErrors value was true, as it is by default, It is possible to see what errors were thrown during the merge of EPS to PDF.
  6. You can download files by using the DownloadFile function: ‘DownloadFile(JSON.fileNameResult, “image/pdf”);’


The following code snippet shows how to merge EPS files into a PDF document in JavaScript:

 1  var fPs2Pdf = function (e) {
 2    const file_reader = new FileReader();
 3    function readFile(index) {
 4      if (index >= e.target.files.length) {
 5          const fileNames = Array.from(e.target.files).map((x) => x.name).toString();
 6          const JSON = PSMergeToPdf(fileNames, "ResultMerge.pdf", true);
 7          if (JSON.errorCode == 0) {
 8            DownloadFile(JSON.fileNameResult, "image/pdf");
 9          }
10          else 
11            document.getElementById('output').textContent = JSON.errorText;
12          return;
13      }
14      const file = e.target.files[index];
15      file_reader.onload = function (event) {
16        AsposePagePrepare(event.target.result, file.name);
17        readFile(index + 1)
18      }
19      file_reader.readAsArrayBuffer(file);
20    }
21    readFile(0);
22  }

See PS/EPS merge in .Net and Java.

Let’s consider some parameters.

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.