Merge PS documents to PDF

JavaScript API solution to combine several PostScript files into a single PDF document

 

PostScript (PS) files, while capable of multiple pages, can’t inherently combine separate files into a single document like XPS. Our Aspose.Page API solution for JavaScript solves this! It empowers you to merge several PS or EPS files into one cohesive PDF document.

See how easy it is to merge PostScript files using JavaScript in the following code example. For web integration or online merging, explore our cross-platform PS Merger tool.

Aspose.Page for JavaScript API, which is a feature-rich, powerful, and easy-to-use document manipulation and conversion API for JavaScript solution.

To merge PS and EPS files, you need:

Steps to merge PostScript files with JavaScript

  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. 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.
  5. You can download files by using the DownloadFile function: ‘DownloadFile(json.fileNameResult, ‘image/pdf’);’

Save EPS as PDF

var fPs2Pdf = function (e) {
 	 const file_reader = new FileReader();
 	 file_reader.onload = (event) => {
 	 function readFile(index) {
 	 	 if (index >= e.target.files.length) {
 	 	 	 const fileNames = Array.from(e.target.files).map((x) => x.name).toString();
 	 	 	 const json = PSMergeToPdf(fileNames, 'ResultMerge.pdf', true);
 	 	 	 if (json.errorCode == 0) {
 	 	 	 	 DownloadFile(json.fileNameResult, 'image/pdf');
 	 	 	 }
 	 	 	 else
 	 	 	 	 document.getElementById('output').textContent = json.errorText;
 	 	 	 return;
 	 	 }
 	 	 const file = e.target.files[index];
 	 	 file_reader.onload = function (event) {
 	 	 	 AsposePagePrepare(event.target.result, file.name);
 	 	 	 readFile(index + 1);
 	 	 }
 	 	 file_reader.readAsArrayBuffer(file);
 	 }
 	 readFile(0);
 }

Merge Encapsulated PostScript files with JavaScript

To merge EPS to PDF you will need to take the same steps as for PS to PDF merging. To learn a more detailed code example, go to Aspose.Page Documentation .

PS What is PS File Format

PS format is one of the page description language (PDL) formats. It is capable to contain graphic as well as text information on the page. That is why the format was supported by most of the programs for image editing. The postscript file itself is a kind of instruction for printers. It contains information on what and how to print from its page.